├── .gitignore ├── images └── kubernetes-standalone.png ├── scripts ├── kube-namespace.sh ├── kube-wait.sh ├── forward.sh ├── dns.sh └── kube-ui.sh ├── examples ├── busybox.yml ├── alpine.yml ├── pi-job.yml ├── nginx.service.json ├── start-service.sh ├── cadvisor.yml └── nginx.controller.json ├── kube-down.sh ├── kube-up.sh ├── manifests └── master.json ├── docker-compose.yml ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /images/kubernetes-standalone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/infrabricks/kubernetes-standalone/HEAD/images/kubernetes-standalone.png -------------------------------------------------------------------------------- /scripts/kube-namespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | kubectl create -f - << EOF 4 | kind: Namespace 5 | apiVersion: v1 6 | metadata: 7 | name: kube-system 8 | labels: 9 | name: kube-system 10 | EOF 11 | 12 | -------------------------------------------------------------------------------- /scripts/kube-wait.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Waiting for Kubernetes cluster to become available..." 3 | 4 | until $(kubectl cluster-info &> /dev/null); do 5 | sleep 1 6 | done 7 | 8 | echo "Kubernetes cluster is up." 9 | -------------------------------------------------------------------------------- /examples/busybox.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: busybox 5 | namespace: default 6 | spec: 7 | containers: 8 | - image: busybox 9 | command: 10 | - sleep 11 | - "3600" 12 | imagePullPolicy: IfNotPresent 13 | name: busybox 14 | restartPolicy: Always 15 | -------------------------------------------------------------------------------- /examples/alpine.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: alpine 5 | namespace: default 6 | spec: 7 | containers: 8 | - image: alpine:3.2 9 | command: 10 | - /bin/sh 11 | - "-c" 12 | - "sleep 60m" 13 | imagePullPolicy: IfNotPresent 14 | name: alpine 15 | restartPolicy: Always 16 | -------------------------------------------------------------------------------- /examples/pi-job.yml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Job 3 | metadata: 4 | name: pi 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: pi 9 | template: 10 | metadata: 11 | name: pi 12 | labels: 13 | app: pi 14 | spec: 15 | containers: 16 | - name: pi 17 | image: perl 18 | command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] 19 | restartPolicy: Never 20 | -------------------------------------------------------------------------------- /examples/nginx.service.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "Service", 3 | "apiVersion": "v1", 4 | "metadata": { 5 | "name": "nginx", 6 | "labels": { 7 | "name": "nginx", 8 | "app": "sample", 9 | "visualize": "true" 10 | } 11 | }, 12 | "spec": { 13 | "ports": [ 14 | { 15 | "name": "http", 16 | "port": 9001, 17 | "targetPort": 80, 18 | "protocol": "TCP" 19 | } 20 | ], 21 | "selector": { 22 | "name": "nginx" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /scripts/forward.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Set up kubectl port forwarding to boot2docker VM if needed. 4 | 5 | function forward_port_if_not_forwarded { 6 | port=$1 7 | machine=$(docker-machine active) 8 | forward_port_command="ssh -f -N -i $HOME/.docker/machine/machines/$machine/id_rsa -L $port:localhost:$port docker@$(docker-machine ip $machine)" 9 | existing_forward=$(ps ax | grep "$forward_port_command" | grep -v grep) 10 | 11 | if [ -z "$existing_forward" ]; then 12 | eval $forward_port_command 13 | fi 14 | } 15 | 16 | # Kubernetes API 17 | forward_port_if_not_forwarded 8080 18 | -------------------------------------------------------------------------------- /kube-down.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Stopping replication controllers, services and pods..." 3 | kubectl stop replicationcontrollers,services,pods --all 4 | if [ $? != 0 ]; then 5 | echo "Kubernetes already down?" 6 | fi 7 | 8 | if [ ! -z "$(docker-compose ps -q)" ]; then 9 | docker-compose stop 10 | docker-compose rm -f -v 11 | fi 12 | 13 | k8s_containers=`docker ps -a -f "name=k8s_" -q` 14 | 15 | if [ ! -z "$k8s_containers" ]; then 16 | echo "Stopping and removing all other containers that were started by Kubernetes..." 17 | docker stop $k8s_containers 18 | docker rm -f -v $k8s_containers 19 | fi 20 | -------------------------------------------------------------------------------- /examples/start-service.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | require_command_exists() { 3 | command -v "$1" >/dev/null 2>&1 || { echo "$1 is required but is not installed. Aborting." >&2; exit 1; } 4 | } 5 | 6 | require_command_exists kubectl 7 | 8 | SERVICE=${1:-nginx} 9 | S_EXISTS=$(kubectl get service -lname=${SERVICE} | tail -n +2) 10 | if [ "z${S_EXISTS}" == "z" ] ; then 11 | kubectl create -f ${SERVICE}.service.json 12 | fi 13 | 14 | RC=${1:-nginx} 15 | RC_EXISTS=$(kubectl get rc -lname=${RC} | tail -n +2) 16 | if [ "z${RC_EXISTS}" == "z" ] ; then 17 | kubectl create -f ${RC}.controller.json 18 | else 19 | kubectl delete rc/${RC} 20 | kubectl create -f ${RC}.controller.json 21 | fi 22 | -------------------------------------------------------------------------------- /kube-up.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | require_command_exists() { 4 | command -v "$1" >/dev/null 2>&1 || { echo "$1 is required but is not installed. Aborting." >&2; exit 1; } 5 | } 6 | 7 | require_command_exists kubectl 8 | require_command_exists docker 9 | require_command_exists docker-compose 10 | 11 | docker info > /dev/null 12 | if [ $? != 0 ]; then 13 | echo "A running Docker engine is required. Is your Docker host up?" 14 | exit 1 15 | fi 16 | 17 | docker-compose up -d 18 | 19 | cd scripts 20 | 21 | if [ $(command -v docker-machine) ] && [ ! -z "$(docker-machine active)" ]; then 22 | ./forward.sh 23 | fi 24 | 25 | ./kube-wait.sh 26 | ./kube-namespace.sh 27 | ./dns.sh 28 | ./kube-ui.sh 29 | -------------------------------------------------------------------------------- /scripts/dns.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dns_host=$(echo $DOCKER_HOST | awk -F'[/:]' '{print $4}') 4 | : ${dns_host:=$(ifconfig docker0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*')} 5 | 6 | kubectl --namespace=kube-system create -f - << EOF 7 | apiVersion: v1 8 | kind: Endpoints 9 | metadata: 10 | name: kube-dns 11 | namespace: kube-system 12 | subsets: 13 | - addresses: 14 | - ip: $dns_host 15 | ports: 16 | - port: 53 17 | protocol: UDP 18 | name: dns 19 | EOF 20 | 21 | kubectl --namespace=kube-system create -f - << EOF 22 | kind: Service 23 | apiVersion: v1 24 | metadata: 25 | name: kube-dns 26 | namespace: kube-system 27 | spec: 28 | clusterIP: 10.0.0.10 29 | ports: 30 | - name: dns 31 | port: 53 32 | protocol: UDP 33 | EOF 34 | -------------------------------------------------------------------------------- /examples/cadvisor.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: cadvisor-agent 5 | spec: 6 | containers: 7 | - name: cadvisor-agent 8 | image: google/cadvisor:0.19.3 9 | ports: 10 | - name: http 11 | containerPort: 8080 12 | hostPort: 4194 13 | volumeMounts: 14 | - name: varrun 15 | mountPath: /var/run 16 | readOnly: false 17 | - name: varlibdocker 18 | mountPath: /var/lib/docker 19 | readOnly: true 20 | - name: sysfs 21 | mountPath: /sys 22 | readOnly: true 23 | volumes: 24 | - name: varrun 25 | source: 26 | hostDir: 27 | path: /var/run 28 | - name: varlibdocker 29 | source: 30 | hostDir: 31 | path: /var/lib/docker 32 | - name: sysfs 33 | source: 34 | hostDir: 35 | path: /sys 36 | -------------------------------------------------------------------------------- /examples/nginx.controller.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind":"ReplicationController", 3 | "apiVersion":"v1", 4 | "metadata":{ 5 | "name":"nginx", 6 | "labels":{ 7 | "name":"nginx", 8 | "visualize": "true" 9 | } 10 | }, 11 | "spec":{ 12 | "replicas": 2, 13 | "selector":{ 14 | "name":"nginx" 15 | }, 16 | "template":{ 17 | "metadata":{ 18 | "labels":{ 19 | "name":"nginx", 20 | "app": "sample", 21 | "version": "0.0.1", 22 | "uses": "nginx", 23 | "visualize": "true" 24 | } 25 | }, 26 | "spec":{ 27 | "containers":[ 28 | { 29 | "name":"nginx", 30 | "image":"nginx", 31 | "livenessProbe": 32 | { "httpGet": { 33 | "path": "/", 34 | "port": 80 35 | }, 36 | "initialDelaySeconds": 15, 37 | "timeoutSeconds": 1 38 | } 39 | } 40 | ] 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /manifests/master.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiVersion": "v1", 3 | "kind": "Pod", 4 | "metadata": {"name":"k8s-master"}, 5 | "spec":{ 6 | "hostNetwork": true, 7 | "containers":[ 8 | { 9 | "name": "controller-manager", 10 | "image": "gcr.io/google_containers/hyperkube:v1.1.8", 11 | "command": [ 12 | "/hyperkube", 13 | "controller-manager", 14 | "--master=127.0.0.1:8080", 15 | "--v=2" 16 | ] 17 | }, 18 | { 19 | "name": "apiserver", 20 | "image": "gcr.io/google_containers/hyperkube:v1.1.8", 21 | "command": [ 22 | "/hyperkube", 23 | "apiserver", 24 | "--service-cluster-ip-range=10.0.0.1/24", 25 | "--bind-address=0.0.0.0", 26 | "--insecure-bind-address=0.0.0.0", 27 | "--secure-port=0", 28 | "--etcd-servers=http://127.0.0.1:4001", 29 | "--cluster-name=kubernetes", 30 | "--v=2" 31 | ] 32 | }, 33 | { 34 | "name": "scheduler", 35 | "image": "gcr.io/google_containers/hyperkube:v1.1.8", 36 | "command": [ 37 | "/hyperkube", 38 | "scheduler", 39 | "--master=127.0.0.1:8080", 40 | "--v=2" 41 | ] 42 | } 43 | ] 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /scripts/kube-ui.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Activating Kube UI..." 4 | 5 | kubectl --namespace=kube-system create -f - << EOF 6 | apiVersion: v1 7 | kind: ReplicationController 8 | metadata: 9 | name: kube-ui-v4 10 | namespace: kube-system 11 | labels: 12 | k8s-app: kube-ui 13 | version: v4 14 | kubernetes.io/cluster-service: "true" 15 | spec: 16 | replicas: 1 17 | selector: 18 | k8s-app: kube-ui 19 | version: v4 20 | template: 21 | metadata: 22 | labels: 23 | k8s-app: kube-ui 24 | version: v4 25 | kubernetes.io/cluster-service: "true" 26 | spec: 27 | containers: 28 | - name: kube-ui 29 | image: gcr.io/google_containers/kube-ui:v4 30 | resources: 31 | limits: 32 | cpu: 100m 33 | memory: 50Mi 34 | ports: 35 | - containerPort: 8080 36 | livenessProbe: 37 | httpGet: 38 | path: / 39 | port: 8080 40 | initialDelaySeconds: 30 41 | timeoutSeconds: 5 42 | EOF 43 | 44 | kubectl --namespace=kube-system create -f - << EOF 45 | apiVersion: v1 46 | kind: Service 47 | metadata: 48 | name: kube-ui 49 | namespace: kube-system 50 | labels: 51 | k8s-app: kube-ui 52 | kubernetes.io/cluster-service: "true" 53 | kubernetes.io/name: "KubeUI" 54 | spec: 55 | selector: 56 | k8s-app: kube-ui 57 | ports: 58 | - port: 80 59 | targetPort: 8080 60 | EOF 61 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | etcd: 2 | image: gcr.io/google_containers/etcd:2.2.1 3 | net: host 4 | container_name: etcd 5 | command: ['/usr/local/bin/etcd', '--addr=127.0.0.1:4001', '--bind-addr=0.0.0.0:4001', '--data-dir=/var/etcd/data'] 6 | kubelet: 7 | image: gcr.io/google_containers/hyperkube:v1.1.8 8 | net: host 9 | pid: host 10 | privileged: true 11 | volumes: 12 | - /:/rootfs:ro 13 | - /sys:/sys:ro 14 | - /dev:/dev 15 | - /var/run/docker.sock:/var/run/docker.sock 16 | - /var/lib/docker/:/var/lib/docker:ro 17 | - /var/lib/kubelet/:/var/lib/kubelet:rw 18 | - /var/run:/var/run:rw 19 | - ./manifests:/etc/kubernetes/manifests:ro 20 | command: /hyperkube kubelet --containerized --api_servers=http://127.0.0.1:8080 --v=2 --address=0.0.0.0 --enable_server --hostname_override=127.0.0.1 --config=/etc/kubernetes/manifests --cluster-dns=10.0.0.10 --cluster-domain=cluster.local 21 | proxy: 22 | image: gcr.io/google_containers/hyperkube:v1.1.8 23 | net: host 24 | pid: host 25 | privileged: true 26 | command: /hyperkube proxy --master=http://127.0.0.1:8080 --v=2 27 | kube2sky: 28 | image: gcr.io/google_containers/kube2sky:1.12 29 | net: host 30 | command: ['--kube_master_url=http://127.0.0.1:8080', '--domain=cluster.local'] 31 | skydns: 32 | image: gcr.io/google_containers/skydns:2015-10-13-8c72f8c 33 | net: host 34 | command: ['--machines=http://localhost:4001', '--addr=0.0.0.0:53', '--domain=cluster.local', '-ns-rotate=false'] 35 | environment: 36 | - SKYDNS_NAMESERVERS=8.8.8.8:53,8.8.4.4:53 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kubernetes single node deployment 2 | 3 | Idea from https://github.com/vyshane/docker-compose-kubernetes 4 | 5 | In the docker-compose.yml file, you see in the commands that it used a single binary hyperkube that allows you to start all the kubernetes components, the API server and the replication controller. One of the components it started is the kubelet which is normally used to monitor containers on one of the host in your cluster and make sure they stay up. Here by passing the `/etc/kubernetes/manifests` it helped us start the other components of kubernetes defined in that manifest. 6 | 7 | Note also that the containers where started with a host networking. So these containers have the network stack of the host, you will not see an interface on the docker bridge. 8 | 9 | With all those up, grab the kubectl binary, that is your kubernetes client that you will use to interact with the system. 10 | 11 | ![](images/kubernetes-standalone.png) 12 | 13 | ## Create a developer kubernetes machine 14 | 15 | ``` 16 | $ docker-machine create -d virtualbox \ 17 | --virtualbox-memory "3072" \ 18 | --virtualbox-cpu-count "2" kubernetes 19 | $ eval $(docker-machine env kubernetes) 20 | $ export KUBERNETES_MASTER=http://127.0.0.1:8080 21 | $ ./kube-up.sh 22 | 23 | ``` 24 | 25 | Quickly there after, you will see a bunch of containers pop-up: 26 | 27 | ``` 28 | $ docker ps --no-trunc --format "{{.Image}} {{.Command}}" 29 | gcr.io/google_containers/pause:0.8.0 "/pause" 30 | gcr.io/google_containers/hyperkube:v1.1.8 "/hyperkube controller-manager --master=127.0.0.1:8080 --v=2" 31 | gcr.io/google_containers/hyperkube:v1.1.8 "/hyperkube scheduler --master=127.0.0.1:8080 --v=2" 32 | gcr.io/google_containers/hyperkube:v1.1.8 "/hyperkube apiserver --service-cluster-ip-range=10.0.0.1/24 --address=127.0.0.1 --etcd-servers=http://127.0.0.1:4001 --cluster-name=kubernetes --v=2" 33 | gcr.io/google_containers/pause:0.8.0 "/pause" 34 | gcr.io/google_containers/etcd:2.0.13 "/usr/local/bin/etcd --addr=127.0.0.1:4001 --bind-addr=0.0.0.0:4001 --data-dir=/var/etcd/data" 35 | gcr.io/google_containers/hyperkube:v1.1.8 "/hyperkube proxy --master=http://127.0.0.1:8080 --v=2" 36 | gcr.io/google_containers/hyperkube:v1.1.8 "/hyperkube kubelet --api_servers=http://127.0.0.1:8080 --v=2 --address=0.0.0.0 --enable_server --hostname_override=127.0.0.1 --config=/etc/kubernetes/manifests" 37 | ``` 38 | 39 | 40 | ## Install the kubectl at your boot2docker images 41 | 42 | ``` 43 | $ docker-machine ssh kubernetes 44 | $ cd /var/lib/boot2docker 45 | $ sudo /bin/sh 46 | $ cat >bootlocal.sh < 80/TCP 131 | Endpoints: 172.17.0.3:80,172.17.0.4:80 132 | Session Affinity: None 133 | No events. 134 | ``` 135 | ## create a job 136 | 137 | ``` 138 | $ cd examples 139 | $ kubectl create -f pi-job.xml 140 | $ kubectl get jobs 141 | JOB CONTAINER(S) IMAGE(S) SELECTOR SUCCESSFUL 142 | pi pi perl app in (pi) 0 143 | $ kubectl get jobs 144 | JOB CONTAINER(S) IMAGE(S) SELECTOR SUCCESSFUL 145 | pi pi perl app in (pi) 1 146 | $ pods=$(kubectl get pods --selector=app=pi --output=jsonpath={.items..metadata.name}) 147 | $ kubectl logs $pods 148 | 3.141592653589793238462643383279502884197169... 149 | ``` 150 | 151 | * https://github.com/kubernetes/kubernetes/blob/release-1.1/docs/user-guide/jobs.md 152 | 153 | ## Remove old master after reboot 154 | 155 | Currently the started master server are not remove if machine has booted. 156 | Every machine restart create new master and pods.. 157 | 158 | Clean up with following command 159 | 160 | ``` 161 | docker rm $(docker ps -f status=exited -q) 162 | ``` 163 | 164 | ## Use your local mac kubectl client 165 | 166 | ``` 167 | $ brew install kubernetes-cli 168 | $ eval $(docker-machine env kubernetes) 169 | $ export KUBERNETES_MASTER=http://127.0.0.1:8080 170 | $ scripts/forward.sh 171 | $ kubectl get nodes 172 | ``` 173 | 174 | 175 | ## Use kubectl bash completion 176 | 177 | ``` 178 | $ cd /usr/local/etc/bash_completion.d 179 | $ curl -Ls https://raw.githubusercontent.com/kubernetes/kubernetes/master/contrib/completions/bash/kubectl >kubectl 180 | $ chmod +x kubectl 181 | ``` 182 | 183 | ## Start the kube-ui 184 | 185 | ``` 186 | $ eval $(docker-machine env kubernetes) 187 | $ export KUBERNETES_MASTER=http://127.0.0.1:8080 188 | $ scripts/kube-ui.sh 189 | $ kubectl --namespace=kube-system get pods 190 | $ kubectl cluster-info 191 | Kubernetes master is running at http://127.0.0.1:8080 192 | KubeUI is running at http://127.0.0.1:8080/api/v1/proxy/namespaces/kube-system/services/kube-ui 193 | ``` 194 | 195 | go to your browser and access the kube-ui with following link 196 | 197 | open http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kube-ui 198 | 199 | ## Alternate kubernetes visualizer 200 | 201 | ``` 202 | $ git clone https://github.com/saturnism/gcp-live-k8s-visualizer 203 | $ cd gcp-live-k8s-visualizer 204 | $ kubectl proxy --port=8011 --www=%(pwd) 205 | $ open browser http://localhost:8011/static/ 206 | $ cd examples 207 | $ kubectl create -f nginx.controller.json 208 | $ kubectl create -f nginx.service.json 209 | ``` 210 | 211 | Add label `visualize=true` to your rc, service and pods descriptions! 212 | 213 | ## Use DNS 214 | 215 | ``` 216 | $ dig @192.168.99.100 nginx.default.svc.cluster.local 217 | 218 | ; <<>> DiG 9.8.3-P1 <<>> @192.168.99.100 nginx.default.svc.cluster.local 219 | ; (1 server found) 220 | ;; global options: +cmd 221 | ;; Got answer: 222 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62706 223 | ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 224 | 225 | ;; QUESTION SECTION: 226 | ;nginx.default.svc.cluster.local. IN A 227 | 228 | ;; ANSWER SECTION: 229 | nginx.default.svc.cluster.local. 30 IN A 172.17.0.74 230 | 231 | ;; Query time: 35 msec 232 | ;; SERVER: 192.168.99.100#53(192.168.99.100) 233 | ;; WHEN: Tue Dec 1 15:48:59 2015 234 | ;; MSG SIZE rcvd: 65 235 | ``` 236 | 237 | other information 238 | 239 | ``` 240 | $ dig +short SRV @192.168.99.100 nginx.default.svc.cluster.local 241 | $ dig +short SRV @$(docker-machine ip kubernetes) nginx.default.svc.cluster.local 242 | $ kubectl describe service nginx 243 | ``` 244 | 245 | ## Access other services 246 | 247 | ``` 248 | cd examples 249 | kubectl create -f busybox.yml 250 | kubectl exec -ti busybox /bin/sh 251 | ping nginx 252 | # not working... 253 | ``` 254 | 255 | ``` 256 | kubectl exec busybox -- nslookup cluster.local 257 | Server: 10.0.0.10 258 | Address 1: 10.0.0.10 259 | 260 | Name: cluster.local 261 | Address 1: 127.0.0.1 localhost 262 | Address 2: 172.17.0.3 263 | Address 3: 172.17.0.2 264 | Address 4: 10.0.0.1 265 | Address 5: 172.17.0.6 266 | Address 6: 10.0.0.10 267 | Address 7: 10.0.0.124 268 | Address 8: 10.0.0.65 269 | Address 9: 172.17.0.4 270 | Address 10: 172.17.0.5 busybox 271 | 272 | ``` 273 | 274 | ``` 275 | kubectl create -f examples/alpine.yml 276 | sleep 2 277 | kubectl exec -ti apline /bin/sh 278 | apk add --update curl 279 | curl nginx.default.svc.cluster.local:9001 280 | ... 281 | ``` 282 | 283 | ## info from kubectl 284 | 285 | ``` 286 | IP=$(docker-machine ip kubernetes) 287 | curl ${IP}:10255/pods | jq "." | more 288 | curl ${IP}:10255/metrics | more 289 | # can directly use with prometheus monitoring system 290 | curl ${IP}:10255/healtz 291 | ``` 292 | 293 | ## cadvisor from Kubectl 294 | 295 | open cadvisor with browser `$IP:4194` 296 | 297 | ## Loadbalancer (ToDo) 298 | 299 | Kubernetes 300 | 301 | * NodePorts 302 | * Loadbalancer 303 | * https://github.com/kubernetes/kubernetes/blob/release-1.1/docs/design/horizontal-pod-autoscaler.md 304 | 305 | ### Ingress 306 | 307 | Edge Server 308 | 309 | * http://kubernetes.io/v1.1/docs/user-guide/ingress.html 310 | * https://github.com/kubernetes/contrib/tree/master/Ingress/controllers/nginx-alpha 311 | * Use a simple loadbalancer 312 | * Add ingress watcher to produce nginx conf 313 | * Dynamic reflect changed ingress definition 314 | 315 | *** 316 | 317 | Regards 318 | 319 | Peter peter.rossbach@bee42.com 320 | 321 | ## Links 322 | 323 | * http://kubernetes.io 324 | * https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/dns 325 | * https://github.com/kubernetes/kubernetes/blob/master/contrib/completions/bash/kubectl 326 | * http://sebgoa.blogspot.de/2015/04/1-command-to-kubernetes-with-docker.html 327 | * https://github.com/vyshane/docker-compose-kubernetes 328 | * https://blog.docker.com/2015/11/deploy-manage-cluster-docker-swarm/ 329 | * http://www.dasblinkenlichten.com/installing-cadvisor-and-heapster-on-bare-metal-kubernetes/ 330 | * https://github.com/kubernetes-ui/graph 331 | * http://sebgoa.blogspot.de/2015/06/introducing-kmachine-docker-machine.html 332 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [2015] bee42 solutions gmbh and 191 | Peter Rossbach 192 | 193 | Licensed under the Apache License, Version 2.0 (the "License"); 194 | you may not use this file except in compliance with the License. 195 | You may obtain a copy of the License at 196 | 197 | http://www.apache.org/licenses/LICENSE-2.0 198 | 199 | Unless required by applicable law or agreed to in writing, software 200 | distributed under the License is distributed on an "AS IS" BASIS, 201 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 202 | See the License for the specific language governing permissions and 203 | limitations under the License. 204 | --------------------------------------------------------------------------------