From 24149a7e636c50d5a1a4ffad8ed41af9bacb3297 Mon Sep 17 00:00:00 2001 From: Pablo Klijnjan Date: Sat, 5 Mar 2016 09:39:47 +0200 Subject: [PATCH] gh-53 Allow to control how to talk to k8s in installer --- docs/installation.md | 19 +++++++++++++++++++ packaging/kubernetes/start-in-k8s | 19 ++++++++++++++++--- packaging/templates/rc-manifest.yml.j2 | 6 +++--- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index 36e4170..6c0f4cc 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -27,8 +27,27 @@ $ sh start-in-k8s The newly created replication controller might take some time to spin up a new pod. After the pod is up, the application should become available. See the usage section to get started. +The installer uses the following defaults to talk to kubernetes: + +- *Cluster address:* http://localhost:8080 +- *kubectl path:* kubectl + +You can control the above by setting the envars: `KUBE_ADMIN_CLUSTER_ADDR` and `KUBE_ADMIN_KUBECTL_PATH` + # Upgrade Untill the install script supports upgrade, use: kubectl rolling-update kube-admin- -f rc-manifest.yml --namespace="kube-system" + +# Alternative install options + +At this moment, the application has no dedicated back-end and it is formed only of static files (javascript, css, html) therefore +is quite simple to just serve this files. For example, using python simple HTTP server module: + + cd dist # dir containing index.html and the compiled static files + python2 -m SimpleHTTPServer + +Now the app is served at localhost:8000 + +To simplify, I just provided the install in kubernetes option, but if there is need for other ways to serve the app, they should be quite easy to add. diff --git a/packaging/kubernetes/start-in-k8s b/packaging/kubernetes/start-in-k8s index 253568a..177a62c 100755 --- a/packaging/kubernetes/start-in-k8s +++ b/packaging/kubernetes/start-in-k8s @@ -1,13 +1,26 @@ #!/usr/bin/bash set -e -KUBE_CLUSTER=http://localhost:8080 -KBIN="kubectl -s $KUBE_CLUSTER" +if [ -z "$KUBE_ADMIN_CLUSTER_ADDR" ]; then + CLUSTER_ADDR=http://localhost:8080 +else + CLUSTER_ADDR="$KUBE_ADMIN_CLUSTER_ADDR" +fi + +if [ -z "$KUBE_ADMIN_KUBECTL_PATH" ]; then + KUBECTL_PATH=kubectl +else + KUBECTL_PATH="$KUBE_ADMIN_KUBECTL_PATH" +fi + +KBIN="$KUBECTL_PATH -s $CLUSTER_ADDR" + +echo "Using kubectl: $KBIN" already_created() { ret_val=1 - if [ $($KBIN get $1 --namespace=kube-system -l k8s-app=kube-admin |awk '{print $1}'|tail -1) = "kube-admin" ]; + if [[ $($KBIN get $1 --namespace=kube-system -l k8s-app=kube-admin |awk '{print $1}'|tail -1) == *"kube-admin"* ]]; then return 0 fi diff --git a/packaging/templates/rc-manifest.yml.j2 b/packaging/templates/rc-manifest.yml.j2 index 2a8b5cc..85f5eff 100644 --- a/packaging/templates/rc-manifest.yml.j2 +++ b/packaging/templates/rc-manifest.yml.j2 @@ -4,18 +4,18 @@ metadata: name: kube-admin-{{ version }} namespace: kube-system labels: - k8s-app: kube-admin-{{ version }} + k8s-app: kube-admin version: {{ version }} kubernetes.io/cluster-service: "true" spec: replicas: 1 selector: - k8s-app: kube-admin-{{ version }} + k8s-app: kube-admin version: {{ version }} template: metadata: labels: - k8s-app: kube-admin-{{ version }} + k8s-app: kube-admin version: {{ version }} kubernetes.io/cluster-service: "true" spec: