├── 00_install-kubernetes ├── 00_install-kubernetes-master.sh ├── 01_install-kubernetes-node.sh ├── README.md └── scripts │ ├── default │ ├── etcd │ ├── kube-apiserver │ ├── kube-controller-manager │ ├── kube-proxy │ ├── kube-scheduler │ └── kubelet │ ├── init.d │ ├── etcd │ ├── kube-apiserver │ ├── kube-controller-manager │ ├── kube-scheduler │ └── kubelet │ └── init │ ├── etcd.conf │ ├── kube-apiserver.conf │ ├── kube-controller-manager.conf │ ├── kube-proxy.conf │ ├── kube-scheduler.conf │ └── kubelet.conf ├── 01_install-contrail ├── 00_contrail-controller-build.md ├── 01_contrail-add-kubernetes-node.md ├── 02_build-kube-network-manager.md ├── 03_contrail-add-static-route.md ├── 04_kubernetes-add-vrouter-gateway.md └── 05_add_static_route_on_nodes_not_running_vgw.md ├── README.md ├── addons ├── README.md ├── dns │ ├── skydns-rc.yaml │ └── skydns-svc.yaml └── kube-ui │ ├── image │ ├── .gitignore │ ├── Dockerfile │ ├── Makefile │ └── kube-ui.go │ ├── kube-system-ns.yaml │ ├── kube-ui-address.yaml │ ├── kube-ui-endpoint.yaml │ ├── kube-ui-rc.yaml │ └── kube-ui-svc.yaml ├── diagrams └── k8s-contrail-logical-diagram.png ├── examples ├── README.md ├── guestbook-go │ ├── guestbook-controller.json │ ├── guestbook-go.sh │ ├── guestbook-page.png │ ├── guestbook-service.json │ ├── redis-master-controller.json │ ├── redis-master-service.json │ ├── redis-slave-controller.json │ └── redis-slave-service.json └── k8petstore │ └── k8petstore.sh └── tools ├── README.md ├── purge.py └── vrouter-restart.sh /00_install-kubernetes/00_install-kubernetes-master.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Taken from https://raw.githubusercontent.com/lachie83/murano-apps/patch-1/Docker/Kubernetes/KubernetesCluster/elements/kubernetes/install.d/57-kubernetes 4 | 5 | apt-get install curl wget linux-libc-dev git gcc libc6-dev bridge-utils haproxy 6 | 7 | SVC_ROOT=/opt/bin 8 | 9 | ETCD_LATEST_VERSION="v2.0.9" 10 | KUBE_LATEST_VERSION="v1.0.1" 11 | 12 | ETCD_LATEST_URL="https://github.com/coreos/etcd/releases/download/${ETCD_LATEST_VERSION}/etcd-${ETCD_LATEST_VERSION}-linux-amd64.tar.gz" 13 | KUBE_LATEST_URL="https://github.com/GoogleCloudPlatform/kubernetes/releases/download/${KUBE_LATEST_VERSION}/kubernetes.tar.gz" 14 | 15 | mkdir -p ${SVC_ROOT} 16 | pushd ${SVC_ROOT} 17 | 18 | # Install latest etcd 19 | wget -O ${SVC_ROOT}/etcd-latest.tar.gz $ETCD_LATEST_URL 20 | tar xzvf ${SVC_ROOT}/etcd-latest.tar.gz 21 | rm -f ${SVC_ROOT}/etcd-latest.tar.gz 22 | 23 | mv ${SVC_ROOT}/etcd-${ETCD_LATEST_VERSION}-linux-amd64/etcd ${SVC_ROOT}/ 24 | mv ${SVC_ROOT}/etcd-${ETCD_LATEST_VERSION}-linux-amd64/etcdctl ${SVC_ROOT}/ 25 | 26 | rm -rf ${SVC_ROOT}/etcd-${ETCD_LATEST_VERSION}-linux-amd64 27 | 28 | # Install latest kubernetes 29 | wget -O ${SVC_ROOT}/kubernetes-latest.tar.gz $KUBE_LATEST_URL 30 | tar xzvf ${SVC_ROOT}/kubernetes-latest.tar.gz 31 | rm -f ${SVC_ROOT}/kubernetes-latest.tar.gz 32 | 33 | tar xzvf ${SVC_ROOT}/kubernetes/server/kubernetes-server-linux-amd64.tar.gz 34 | mv ${SVC_ROOT}/kubernetes ${SVC_ROOT}/kubernetes-latest 35 | 36 | cp ${SVC_ROOT}/kubernetes-latest/server/bin/* ${SVC_ROOT}/ 37 | 38 | rm -rf ${SVC_ROOT}/kubernetes-latest 39 | 40 | # Install Go 41 | wget -O go.tar.gz https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz 42 | tar xzvf go.tar.gz 43 | mv ${SVC_ROOT}/go /usr/local/go 44 | export PATH=$PATH:/usr/local/go/bin 45 | 46 | # Update system PATH 47 | sed -i 's/PATH="/PATH="\/opt\/bin:\/usr\/local\/go\/bin:/g' /etc/environment 48 | popd 49 | -------------------------------------------------------------------------------- /00_install-kubernetes/01_install-kubernetes-node.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Taken from https://raw.githubusercontent.com/lachie83/murano-apps/patch-1/Docker/Kubernetes/KubernetesCluster/elements/kubernetes/install.d/57-kubernetes 4 | 5 | apt-get install curl wget linux-libc-dev git gcc libc6-dev bridge-utils haproxy 6 | 7 | SVC_ROOT=/opt/bin 8 | 9 | KUBE_LATEST_VERSION="v1.0.1" 10 | 11 | KUBE_LATEST_URL="https://github.com/GoogleCloudPlatform/kubernetes/releases/download/${KUBE_LATEST_VERSION}/kubernetes.tar.gz" 12 | 13 | mkdir -p ${SVC_ROOT} 14 | pushd ${SVC_ROOT} 15 | 16 | # Install latest kubernetes 17 | wget -O ${SVC_ROOT}/kubernetes-latest.tar.gz $KUBE_LATEST_URL 18 | tar xzvf ${SVC_ROOT}/kubernetes-latest.tar.gz 19 | rm -f ${SVC_ROOT}/kubernetes-latest.tar.gz 20 | 21 | tar xzvf ${SVC_ROOT}/kubernetes/server/kubernetes-server-linux-amd64.tar.gz 22 | mv ${SVC_ROOT}/kubernetes ${SVC_ROOT}/kubernetes-latest 23 | 24 | cp ${SVC_ROOT}/kubernetes-latest/server/bin/* ${SVC_ROOT}/ 25 | 26 | rm -rf ${SVC_ROOT}/kubernetes-latest 27 | 28 | # Install Go 29 | wget -O go.tar.gz https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz 30 | tar xzvf go.tar.gz 31 | mv ${SVC_ROOT}/go /usr/local/go 32 | export PATH=$PATH:/usr/local/go/bin 33 | 34 | # Update system PATH 35 | sed -i 's/PATH="/PATH="\/opt\/bin:\/usr\/local\/go\/bin:/g' /etc/environment 36 | popd 37 | -------------------------------------------------------------------------------- /00_install-kubernetes/README.md: -------------------------------------------------------------------------------- 1 | # Install Kubernetes 2 | 3 | ## Prerequisites 4 | 5 | * Ubuntu 14.04 host 6 | 7 | ## Roles & Services 8 | 9 | * Kubernetes Master 10 | * etcd 11 | * kube-apiserver 12 | * kube-scheduler 13 | * kube-controller-manager 14 | 15 | * Kubernetes Node 16 | * kubelet 17 | 18 | * NB. kube-proxy is not needed in this configuration. 19 | 20 | # Installation 21 | 22 | * Run the shell script corresponding to the role 23 | * Alternatively you can run 00_install-kubernetes-master.sh and snapshot the instance and then deploy services depending on the role. 24 | 25 | # Post-Installation 26 | 27 | * Copy the /etc/init.d, /etc/init and /etc/default scripts for the services running on the corresponding node 28 | * Make the modifications to /etc/default/ to suit your environment 29 | 30 | # Starting 31 | 32 | * Use upstart to start/stop/restart the services 33 | * eg. ```service kubelet start``` 34 | 35 | # Caveats 36 | 37 | * Log directories don't appear to be created 38 | * ```mkdir -p /var/log/kubernetes``` 39 | -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/default/etcd: -------------------------------------------------------------------------------- 1 | ETCD_OPTS="--name kubernetes --data-dir /var/lib/etcd --snapshot-count 1000 --listen-peer-urls http://10.161.136.17:7001,http://127.0.0.1:7001 --listen-client-urls http://10.161.136.17:4001,http://127.0.0.1:4001 --initial-advertise-peer-urls http://10.161.136.17:7001 --initial-cluster-state new --initial-cluster-token new-token --initial-cluster kubernetes=http://10.161.136.17:7001 --advertise-client-urls http://10.161.136.17:4001,http://127.0.0.1:4001" 2 | -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/default/kube-apiserver: -------------------------------------------------------------------------------- 1 | #Kube-Apiserver Upstart and SysVinit configuration file 2 | 3 | # Customize kube-apiserver binary location 4 | # KUBE_APISERVER="/opt/bin/kube-apiserver" 5 | 6 | # Use KUBE_APISERVER_OPTS to modify the start/restart options 7 | KUBE_APISERVER_OPTS="--address=0.0.0.0 \ 8 | --port=8080 \ 9 | --etcd_servers=http://127.0.0.1:4001 \ 10 | --logtostderr=false \ 11 | --portal_net=10.254.0.0/16 --log_dir=/var/log/kubernetes" 12 | 13 | # Add more envionrment settings used by kube-apiserver here 14 | -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/default/kube-controller-manager: -------------------------------------------------------------------------------- 1 | # Kube-Controller-Manager Upstart and SysVinit configuration file 2 | 3 | # Customize kube-controller-manager binary location 4 | # KUBE_CONTROLLER_MANAGER="/opt/bin/kube-controller-manager" 5 | 6 | # Use KUBE_CONTROLLER_MANAGER_OPTS to modify the start/restart options 7 | KUBE_CONTROLLER_MANAGER_OPTS="--master=127.0.0.1:8080 \ 8 | --logtostderr=false --log_dir=/var/log/kubernetes" 9 | 10 | # Add more envionrment settings used by kube-controller-manager here 11 | -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/default/kube-proxy: -------------------------------------------------------------------------------- 1 | # Kube-Proxy Upstart and SysVinit configuration file 2 | 3 | # Customize kube-proxy binary location 4 | # KUBE_PROXY="/opt/bin/kube-proxy" 5 | 6 | # Use KUBE_PROXY_OPTS to modify the start/restart options 7 | KUBE_PROXY_OPTS="--logtostderr=false --master=http://10.161.136.17:8080 --log_dir=/var/log/kubernetes" 8 | 9 | # Add more envionrment settings used by kube-apiserver here 10 | -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/default/kube-scheduler: -------------------------------------------------------------------------------- 1 | # Kube-Scheduler Upstart and SysVinit configuration file 2 | 3 | # Customize kube-apiserver binary location 4 | # KUBE_SCHEDULER="/opt/bin/kube-apiserver" 5 | 6 | # Use KUBE_SCHEDULER_OPTS to modify the start/restart options 7 | KUBE_SCHEDULER_OPTS="--logtostderr=false --log_dir=/var/log/kubernetes \ 8 | --master=10.161.136.17:8080 --address=10.161.136.17" 9 | 10 | # Add more envionrment settings used by kube-scheduler here 11 | -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/default/kubelet: -------------------------------------------------------------------------------- 1 | # Kubelet Upstart and SysVinit configuration file 2 | 3 | # Customize kubelet binary location 4 | # KUBELET="/opt/bin/kubelet" 5 | 6 | # Use KUBELET_OPTS to modify the start/restart options 7 | KUBELET_OPTS="--address=10.161.136.19 \ 8 | --port=10250 \ 9 | --hostname_override=10.161.136.19 \ 10 | --api_servers=http://10.161.136.17:8080 \ 11 | --logtostderr=false \ 12 | --log_dir=/var/log/kubernetes \ 13 | --network_plugin=opencontrail \ 14 | --cluster_dns=10.161.132.53 \ 15 | --cluster_domain=kubernetes.io " 16 | 17 | # Add more envionrment settings used by kube-scheduler here 18 | -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/init.d/etcd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | ### BEGIN INIT INFO 5 | # Provides: etcd 6 | # Required-Start: $docker 7 | # Required-Stop: 8 | # Should-Start: 9 | # Should-Stop: 10 | # Default-Start: 11 | # Default-Stop: 12 | # Short-Description: Start distributed key/value pair service 13 | # Description: 14 | # http://www.github.com/coreos/etcd 15 | ### END INIT INFO 16 | 17 | export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/opt/bin: 18 | 19 | BASE=$(basename $0) 20 | 21 | # modify these in /etc/default/$BASE (/etc/default/etcd) 22 | ETCD=/opt/bin/$BASE 23 | # This is the pid file managed by etcd itself 24 | ETCD_PIDFILE=/var/run/$BASE.pid 25 | ETCD_LOGFILE=/var/log/$BASE.log 26 | ETCD_OPTS="" 27 | ETCD_DESC="Etcd" 28 | 29 | # Get lsb functions 30 | . /lib/lsb/init-functions 31 | 32 | if [ -f /etc/default/$BASE ]; then 33 | . /etc/default/$BASE 34 | fi 35 | 36 | # see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it) 37 | if false && [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then 38 | log_failure_msg "$ETCD_DESC is managed via upstart, try using service $BASE $1" 39 | exit 1 40 | fi 41 | 42 | # Check etcd is present 43 | if [ ! -x $ETCD ]; then 44 | log_failure_msg "$ETCD not present or not executable" 45 | exit 1 46 | fi 47 | 48 | fail_unless_root() { 49 | if [ "$(id -u)" != '0' ]; then 50 | log_failure_msg "$ETCD_DESC must be run as root" 51 | exit 1 52 | fi 53 | } 54 | 55 | ETCD_START="start-stop-daemon \ 56 | --start \ 57 | --background \ 58 | --quiet \ 59 | --exec $ETCD \ 60 | --make-pidfile \ 61 | --pidfile $ETCD_PIDFILE \ 62 | -- $ETCD_OPTS \ 63 | >> $ETCD_LOGFILE 2>&1" 64 | 65 | ETCD_STOP="start-stop-daemon \ 66 | --stop \ 67 | --pidfile $ETCD_PIDFILE" 68 | 69 | case "$1" in 70 | start) 71 | fail_unless_root 72 | log_begin_msg "Starting $ETCD_DESC: $BASE" 73 | $ETCD_START 74 | log_end_msg $? 75 | ;; 76 | 77 | stop) 78 | fail_unless_root 79 | log_begin_msg "Stopping $ETCD_DESC: $BASE" 80 | $ETCD_STOP 81 | log_end_msg $? 82 | ;; 83 | 84 | restart | force-reload) 85 | fail_unless_root 86 | log_begin_msg "Restarting $ETCD_DESC: $BASE" 87 | $ETCD_STOP 88 | $ETCD_START 89 | log_end_msg $? 90 | ;; 91 | 92 | status) 93 | status_of_proc -p "$ETCD_PIDFILE" "$ETCD" "$ETCD_DESC" 94 | ;; 95 | 96 | *) 97 | echo "Usage: $0 {start|stop|restart|status}" 98 | exit 1 99 | ;; 100 | esac 101 | -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/init.d/kube-apiserver: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | ### BEGIN INIT INFO 5 | # Provides: kube-apiserver 6 | # Required-Start: $etcd 7 | # Required-Stop: 8 | # Should-Start: 9 | # Should-Stop: 10 | # Default-Start: 11 | # Default-Stop: 12 | # Short-Description: Start distrubted key/value pair service 13 | # Description: 14 | # http://www.github.com/GoogleCloudPlatform/Kubernetes 15 | ### END INIT INFO 16 | 17 | export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/opt/bin: 18 | 19 | BASE=$(basename $0) 20 | 21 | # modify these in /etc/default/$BASE (/etc/default/kube-apiserver) 22 | KUBE_APISERVER=/opt/bin/$BASE 23 | # This is the pid file managed by kube-apiserver itself 24 | KUBE_APISERVER_PIDFILE=/var/run/$BASE.pid 25 | KUBE_APISERVER_LOGFILE=/var/log/$BASE.log 26 | KUBE_APISERVER_OPTS="" 27 | KUBE_APISERVER_DESC="Kube-Apiserver" 28 | 29 | # Get lsb functions 30 | . /lib/lsb/init-functions 31 | 32 | if [ -f /etc/default/$BASE ]; then 33 | . /etc/default/$BASE 34 | fi 35 | 36 | # see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it) 37 | if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then 38 | log_failure_msg "$KUBE_APISERVER_DESC is managed via upstart, try using service $BASE $1" 39 | exit 1 40 | fi 41 | 42 | # Check kube-apiserver is present 43 | if [ ! -x $KUBE_APISERVER ]; then 44 | log_failure_msg "$KUBE_APISERVER not present or not executable" 45 | exit 1 46 | fi 47 | 48 | fail_unless_root() { 49 | if [ "$(id -u)" != '0' ]; then 50 | log_failure_msg "$KUBE_APISERVER_DESC must be run as root" 51 | exit 1 52 | fi 53 | } 54 | 55 | KUBE_APISERVER_START="start-stop-daemon \ 56 | --start \ 57 | --background \ 58 | --quiet \ 59 | --exec $KUBE_APISERVER \ 60 | --make-pidfile --pidfile $KUBE_APISERVER_PIDFILE \ 61 | -- $KUBE_APISERVER_OPTS \ 62 | >> $KUBE_APISERVER_LOGFILE 2>&1" 63 | 64 | KUBE_APISERVER_STOP="start-stop-daemon \ 65 | --stop \ 66 | --pidfile $KUBE_APISERVER_PIDFILE" 67 | 68 | case "$1" in 69 | start) 70 | fail_unless_root 71 | log_begin_msg "Starting $KUBE_APISERVER_DESC: $BASE" 72 | $KUBE_APISERVER_START 73 | log_end_msg $? 74 | ;; 75 | 76 | stop) 77 | fail_unless_root 78 | log_begin_msg "Stopping $KUBE_APISERVER_DESC: $BASE" 79 | $KUBE_APISERVER_STOP 80 | log_end_msg $? 81 | ;; 82 | 83 | restart | force-reload) 84 | fail_unless_root 85 | log_begin_msg "Stopping $KUBE_APISERVER_DESC: $BASE" 86 | $KUBE_APISERVER_STOP 87 | $KUBE_APISERVER_START 88 | log_end_msg $? 89 | ;; 90 | 91 | status) 92 | status_of_proc -p "$KUBE_APISERVER_PIDFILE" "$KUBE_APISERVER" "$KUBE_APISERVER_DESC" 93 | ;; 94 | 95 | *) 96 | echo "Usage: $0 {start|stop|restart|status}" 97 | exit 1 98 | ;; 99 | esac 100 | -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/init.d/kube-controller-manager: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | ### BEGIN INIT INFO 5 | # Provides: kube-controller-manager 6 | # Required-Start: $etcd 7 | # Required-Stop: 8 | # Should-Start: 9 | # Should-Stop: 10 | # Default-Start: 11 | # Default-Stop: 12 | # Short-Description: Start distrubted key/value pair service 13 | # Description: 14 | # http://www.github.com/GoogleCloudPlatform/Kubernetes 15 | ### END INIT INFO 16 | 17 | export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/opt/bin: 18 | 19 | BASE=$(basename $0) 20 | 21 | # modify these in /etc/default/$BASE (/etc/default/kube-controller-manager) 22 | KUBE_CONTROLLER_MANAGER=/opt/bin/$BASE 23 | # This is the pid file managed by kube-controller-manager itself 24 | KUBE_CONTROLLER_MANAGER_PIDFILE=/var/run/$BASE.pid 25 | KUBE_CONTROLLER_MANAGER_LOGFILE=/var/log/$BASE.log 26 | KUBE_CONTROLLER_MANAGER_OPTS="" 27 | KUBE_CONTROLLER_MANAGER_DESC="Kube-Controller-Manager" 28 | 29 | # Get lsb functions 30 | . /lib/lsb/init-functions 31 | 32 | if [ -f /etc/default/$BASE ]; then 33 | . /etc/default/$BASE 34 | fi 35 | 36 | # see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it) 37 | if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then 38 | log_failure_msg "$KUBE_CONTROLLER_MANAGER_DESC is managed via upstart, try using service $BASE $1" 39 | exit 1 40 | fi 41 | 42 | # Check kube-controller-manager is present 43 | if [ ! -x $KUBE_CONTROLLER_MANAGER ]; then 44 | log_failure_msg "$KUBE_CONTROLLER_MANAGER not present or not executable" 45 | exit 1 46 | fi 47 | 48 | fail_unless_root() { 49 | if [ "$(id -u)" != '0' ]; then 50 | log_failure_msg "$KUBE_CONTROLLER_MANAGER_DESC must be run as root" 51 | exit 1 52 | fi 53 | } 54 | 55 | KUBE_CONTROLLER_MANAGER_START="start-stop-daemon 56 | --start --background \ 57 | --quiet \ 58 | --exec $KUBE_CONTROLLER_MANAGER \ 59 | --make-pidfile \ 60 | --pidfile $KUBE_CONTROLLER_MANAGER_PIDFILE \ 61 | -- $KUBE_CONTROLLER_MANAGER_OPTS \ 62 | >> "$KUBE_CONTROLLER_MANAGER_LOGFILE" 2>&1 63 | 64 | KUBE_CONTROLLER_MANAGER_STOP="start-stop-daemon \ 65 | --stop \ 66 | --pidfile $KUBE_CONTROLLER_MANAGER_PIDFILE" 67 | 68 | case "$1" in 69 | start) 70 | fail_unless_root 71 | log_begin_msg "Starting $KUBE_CONTROLLER_MANAGER_DESC: $BASE" 72 | $KUBE_CONTROLLER_MANAGER_START 73 | log_end_msg $? 74 | ;; 75 | 76 | stop) 77 | fail_unless_root 78 | log_begin_msg "Stopping $KUBE_CONTROLLER_MANAGER_DESC: $BASE" 79 | $KUBE_CONTROLLER_MANAGER_STOP 80 | log_end_msg $? 81 | ;; 82 | 83 | restart | force-reload) 84 | fail_unless_root 85 | log_daemon_message "Restarting $KUBE_CONTROLLER_MANAGER" || true 86 | $KUBE_CONTROLLER_MANAGER_STOP 87 | $KUBE_CONTROLLER_MANAGER_START 88 | log_end_msg $? 89 | ;; 90 | 91 | status) 92 | status_of_proc -p "$KUBE_CONTROLLER_MANAGER_PIDFILE" "$KUBE_CONTROLLER_MANAGER" "$KUBE_CONTROLLER_MANAGER_DESC" 93 | ;; 94 | 95 | *) 96 | echo "Usage: $0 {start|stop|restart|status}" 97 | exit 1 98 | ;; 99 | esac 100 | -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/init.d/kube-scheduler: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | ### BEGIN INIT INFO 5 | # Provides: kube-scheduler 6 | # Required-Start: $etcd 7 | # Required-Stop: 8 | # Should-Start: 9 | # Should-Stop: 10 | # Default-Start: 11 | # Default-Stop: 12 | # Short-Description: Start kube-proxy service 13 | # Description: 14 | # http://www.github.com/GoogleCloudPlatform/Kubernetes 15 | ### END INIT INFO 16 | 17 | export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/opt/bin: 18 | 19 | BASE=$(basename $0) 20 | 21 | # modify these in /etc/default/$BASE (/etc/default/kube-scheduler) 22 | KUBE_SCHEDULER=/opt/bin/$BASE 23 | # This is the pid file managed by kube-scheduler itself 24 | KUBE_SCHEDULER_PIDFILE=/var/run/$BASE.pid 25 | KUBE_SCHEDULER_LOGFILE=/var/log/$BASE.log 26 | KUBE_SCHEDULER_OPTS="" 27 | KUBE_SCHEDULER_DESC="Kube-Scheduler" 28 | 29 | # Get lsb functions 30 | . /lib/lsb/init-functions 31 | 32 | if [ -f /etc/default/$BASE ]; then 33 | . /etc/default/$BASE 34 | fi 35 | 36 | # see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it) 37 | if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then 38 | log_failure_msg "$KUBE_SCHEDULER_DESC is managed via upstart, try using service $BASE $1" 39 | exit 1 40 | fi 41 | 42 | # Check kube-scheduler is present 43 | if [ ! -x $KUBE_SCHEDULER ]; then 44 | log_failure_msg "$KUBE_SCHEDULER not present or not executable" 45 | exit 1 46 | fi 47 | 48 | fail_unless_root() { 49 | if [ "$(id -u)" != '0' ]; then 50 | log_failure_msg "$KUBE_SCHEDULER_DESC must be run as root" 51 | exit 1 52 | fi 53 | } 54 | 55 | KUBE_SCHEDULER_START="start-stop-daemon \ 56 | --start \ 57 | --background \ 58 | --quiet \ 59 | --exec $KUBE_SCHEDULER \ 60 | --make-pidfile --pidfile $KUBE_SCHEDULER_PIDFILE \ 61 | -- $KUBE_SCHEDULER_OPTS \ 62 | >> $KUBE_SCHEDULER_LOGFILE 2>&1" 63 | 64 | KUBE_SCHEDULER_STOP="start-stop-daemon \ 65 | --stop \ 66 | --pidfile $KUBE_SCHEDULER_PIDFILE" 67 | 68 | case "$1" in 69 | start) 70 | fail_unless_root 71 | log_begin_msg "Starting $KUBE_SCHEDULER_DESC: $BASE" 72 | $KUBE_SCHEDULER_START 73 | log_end_msg $? 74 | ;; 75 | 76 | stop) 77 | fail_unless_root 78 | log_begin_msg "Stopping $KUBE_SCHEDULER_DESC: $BASE" 79 | $KUBE_SCHEDULER_STOP 80 | log_end_msg $? 81 | ;; 82 | 83 | restart | force-reload) 84 | fail_unless_root 85 | log_begin_msg "Restarting $KUBE_SCHEDULER_DESC: $BASE" 86 | $KUBE_SCHEDULER_STOP 87 | $KUBE_SCHEDULER_START 88 | log_end_msg $? 89 | ;; 90 | 91 | status) 92 | status_of_proc -p "$KUBE_SCHEDULER_PIDFILE" "$KUBE_SCHEDULER" "$KUBE_SCHEDULER_DESC" 93 | ;; 94 | 95 | *) 96 | echo "Usage: $0 {start|stop|restart|status}" 97 | exit 1 98 | ;; 99 | esac 100 | -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/init.d/kubelet: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | ### BEGIN INIT INFO 5 | # Provides: kubelet 6 | # Required-Start: $etcd 7 | # Required-Stop: 8 | # Should-Start: 9 | # Should-Stop: 10 | # Default-Start: 11 | # Default-Stop: 12 | # Short-Description: Start kubelet service 13 | # Description: 14 | # http://www.github.com/GoogleCloudPlatform/Kubernetes 15 | ### END INIT INFO 16 | 17 | export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/opt/bin: 18 | 19 | BASE=$(basename $0) 20 | 21 | # modify these in /etc/default/$BASE (/etc/default/kube-apiserver) 22 | KUBELET=/opt/bin/$BASE 23 | # This is the pid file managed by kube-apiserver itself 24 | KUBELET_PIDFILE=/var/run/$BASE.pid 25 | KUBELET_LOGFILE=/var/log/$BASE.log 26 | KUBELET_OPTS="" 27 | KUBELET_DESC="Kube-Apiserver" 28 | 29 | # Get lsb functions 30 | . /lib/lsb/init-functions 31 | 32 | if [ -f /etc/default/$BASE ]; then 33 | . /etc/default/$BASE 34 | fi 35 | 36 | # see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it) 37 | if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then 38 | log_failure_msg "$KUBELET_DESC is managed via upstart, try using service $BASE $1" 39 | exit 1 40 | fi 41 | 42 | # Check kube-apiserver is present 43 | if [ ! -x $KUBELET ]; then 44 | log_failure_msg "$KUBELET not present or not executable" 45 | exit 1 46 | fi 47 | 48 | fail_unless_root() { 49 | if [ "$(id -u)" != '0' ]; then 50 | log_failure_msg "$KUBELET_DESC must be run as root" 51 | exit 1 52 | fi 53 | } 54 | 55 | KUBELET_START="start-stop-daemon \ 56 | --start \ 57 | --background \ 58 | --quiet \ 59 | --exec $KUBELET \ 60 | --make-pidfile --pidfile $KUBELET_PIDFILE \ 61 | -- $KUBELET_OPTS \ 62 | >> $KUBELET_LOGFILE 2>&1" 63 | 64 | KUBELET_STOP="start-stop-daemon \ 65 | --stop \ 66 | --pidfile $KUBELET_PIDFILE" 67 | 68 | case "$1" in 69 | start) 70 | fail_unless_root 71 | log_begin_msg "Starting $KUBELET_DESC: $BASE" 72 | $KUBELET_START 73 | log_end_msg $? 74 | ;; 75 | 76 | stop) 77 | fail_unless_root 78 | log_begin_msg "Stopping $KUBELET_DESC: $BASE" 79 | $KUBELET_STOP 80 | log_end_msg $? 81 | ;; 82 | 83 | restart | force-reload) 84 | fail_unless_root 85 | log_begin_msg "Stopping $KUBELET_DESC: $BASE" 86 | $KUBELET_STOP 87 | $KUBELET_START 88 | log_end_msg $? 89 | ;; 90 | 91 | status) 92 | status_of_proc -p "$KUBELET_PIDFILE" "$KUBELET" "$KUBELET_DESC" 93 | ;; 94 | 95 | *) 96 | echo "Usage: $0 {start|stop|restart|status}" 97 | exit 1 98 | ;; 99 | esac 100 | -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/init/etcd.conf: -------------------------------------------------------------------------------- 1 | description "Etcd service" 2 | author "@jainvipin" 3 | 4 | respawn 5 | 6 | pre-start script 7 | # see also https://github.com/jainvipin/kubernetes-ubuntu-start 8 | ETCD=/opt/bin/$UPSTART_JOB 9 | if [ -f /etc/default/$UPSTART_JOB ]; then 10 | . /etc/default/$UPSTART_JOB 11 | fi 12 | if [ -f $ETCD ]; then 13 | exit 0 14 | fi 15 | echo "$ETCD binary not found, exiting" 16 | exit 22 17 | end script 18 | 19 | script 20 | # modify these in /etc/default/$UPSTART_JOB (/etc/default/docker) 21 | ETCD=/opt/bin/$UPSTART_JOB 22 | ETCD_OPTS="" 23 | if [ -f /etc/default/$UPSTART_JOB ]; then 24 | . /etc/default/$UPSTART_JOB 25 | fi 26 | exec "$ETCD" $ETCD_OPTS 27 | end script 28 | 29 | start on runlevel [235] 30 | stop on runlevel [016] -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/init/kube-apiserver.conf: -------------------------------------------------------------------------------- 1 | description "Kube-Apiserver service" 2 | author "@jainvipin" 3 | 4 | # respawn 5 | 6 | # start in conjunction with etcd 7 | start on started etcd 8 | stop on stopping etcd 9 | 10 | pre-start script 11 | # see also https://github.com/jainvipin/kubernetes-start 12 | KUBE_APISERVER=/opt/bin/$UPSTART_JOB 13 | if [ -f /etc/default/$UPSTART_JOB ]; then 14 | . /etc/default/$UPSTART_JOB 15 | fi 16 | if [ -f $KUBE_APISERVER ]; then 17 | exit 0 18 | fi 19 | exit 22 20 | end script 21 | 22 | script 23 | # modify these in /etc/default/$UPSTART_JOB (/etc/default/docker) 24 | KUBE_APISERVER=/opt/bin/$UPSTART_JOB 25 | KUBE_APISERVER_OPTS="" 26 | if [ -f /etc/default/$UPSTART_JOB ]; then 27 | . /etc/default/$UPSTART_JOB 28 | fi 29 | exec "$KUBE_APISERVER" $KUBE_APISERVER_OPTS 30 | end script 31 | 32 | start on runlevel [235] 33 | stop on runlevel [016] -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/init/kube-controller-manager.conf: -------------------------------------------------------------------------------- 1 | description "Kube-Controller-Manager service" 2 | author "@jainvipin" 3 | 4 | # respawn 5 | 6 | # start in conjunction with etcd 7 | start on started etcd 8 | stop on stopping etcd 9 | 10 | pre-start script 11 | # see also https://github.com/jainvipin/kubernetes-ubuntu-start 12 | KUBE_CONTROLLER_MANAGER=/opt/bin/$UPSTART_JOB 13 | if [ -f /etc/default/$UPSTART_JOB ]; then 14 | . /etc/default/$UPSTART_JOB 15 | fi 16 | if [ -f $KUBE_CONTROLLER_MANAGER ]; then 17 | exit 0 18 | fi 19 | exit 22 20 | end script 21 | 22 | script 23 | # modify these in /etc/default/$UPSTART_JOB (/etc/default/docker) 24 | KUBE_CONTROLLER_MANAGER=/opt/bin/$UPSTART_JOB 25 | KUBE_CONTROLLER_MANAGER_OPTS="" 26 | if [ -f /etc/default/$UPSTART_JOB ]; then 27 | . /etc/default/$UPSTART_JOB 28 | fi 29 | exec "$KUBE_CONTROLLER_MANAGER" $KUBE_CONTROLLER_MANAGER_OPTS 30 | end script 31 | 32 | start on runlevel [235] 33 | stop on runlevel [016] -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/init/kube-proxy.conf: -------------------------------------------------------------------------------- 1 | description "Kube-Proxy service" 2 | author "@jainvipin" 3 | 4 | # respawn 5 | 6 | # start in conjunction with etcd 7 | start on started etcd 8 | stop on stopping etcd 9 | 10 | pre-start script 11 | # see also https://github.com/jainvipin/kubernetes-start 12 | KUBE_PROXY=/opt/bin/$UPSTART_JOB 13 | if [ -f /etc/default/$UPSTART_JOB ]; then 14 | . /etc/default/$UPSTART_JOB 15 | fi 16 | if [ -f $KUBE_PROXY ]; then 17 | exit 0 18 | fi 19 | exit 22 20 | end script 21 | 22 | script 23 | # modify these in /etc/default/$UPSTART_JOB (/etc/default/docker) 24 | KUBE_PROXY=/opt/bin/$UPSTART_JOB 25 | KUBE_PROXY_OPTS="" 26 | if [ -f /etc/default/$UPSTART_JOB ]; then 27 | . /etc/default/$UPSTART_JOB 28 | fi 29 | exec "$KUBE_PROXY" $KUBE_PROXY_OPTS 30 | end script 31 | 32 | start on runlevel [235] 33 | stop on runlevel [016] -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/init/kube-scheduler.conf: -------------------------------------------------------------------------------- 1 | description "Kube-Scheduler service" 2 | author "@jainvipin" 3 | 4 | # respawn 5 | 6 | # start in conjunction with etcd 7 | start on started etcd 8 | stop on stopping etcd 9 | 10 | pre-start script 11 | # see also https://github.com/jainvipin/kubernetes-start 12 | KUBE_SCHEDULER=/opt/bin/$UPSTART_JOB 13 | if [ -f /etc/default/$UPSTART_JOB ]; then 14 | . /etc/default/$UPSTART_JOB 15 | fi 16 | if [ -f $KUBE_SCHEDULER ]; then 17 | exit 0 18 | fi 19 | exit 22 20 | end script 21 | 22 | script 23 | # modify these in /etc/default/$UPSTART_JOB (/etc/default/docker) 24 | KUBE_SCHEDULER=/opt/bin/$UPSTART_JOB 25 | KUBE_SCHEDULER_OPTS="" 26 | if [ -f /etc/default/$UPSTART_JOB ]; then 27 | . /etc/default/$UPSTART_JOB 28 | fi 29 | exec "$KUBE_SCHEDULER" $KUBE_SCHEDULER_OPTS 30 | end script 31 | 32 | start on runlevel [235] 33 | stop on runlevel [016] -------------------------------------------------------------------------------- /00_install-kubernetes/scripts/init/kubelet.conf: -------------------------------------------------------------------------------- 1 | description "Kubelet service" 2 | author "@jainvipin" 3 | 4 | # respawn 5 | 6 | # start in conjunction with etcd 7 | start on started etcd 8 | stop on stopping etcd 9 | 10 | pre-start script 11 | # see also https://github.com/jainvipin/kubernetes-ubuntu-start 12 | KUBELET=/opt/bin/$UPSTART_JOB 13 | if [ -f /etc/default/$UPSTART_JOB ]; then 14 | . /etc/default/$UPSTART_JOB 15 | fi 16 | if [ -f $KUBELET ]; then 17 | exit 0 18 | fi 19 | exit 22 20 | end script 21 | 22 | script 23 | # modify these in /etc/default/$UPSTART_JOB (/etc/default/docker) 24 | KUBELET=/opt/bin/$UPSTART_JOB 25 | KUBELET_OPTS="" 26 | if [ -f /etc/default/$UPSTART_JOB ]; then 27 | . /etc/default/$UPSTART_JOB 28 | fi 29 | exec "$KUBELET" $KUBELET_OPTS 30 | end script 31 | 32 | start on runlevel [235] 33 | stop on runlevel [016] 34 | -------------------------------------------------------------------------------- /01_install-contrail/00_contrail-controller-build.md: -------------------------------------------------------------------------------- 1 | # Building Contrail Controller and the kube-network-manager (on the k8s master node) 2 | 3 | ``` 4 | sudo apt-get install git ruby 5 | git clone -b https://github.com/Juniper/contrail-kubernetes 6 | ``` 7 | 8 | # Make sure all the nodes are in /etc/hosts 9 | ``` 10 | 10.161.136.17 kubernetes-master-01 11 | 10.161.136.19 kubernetes-node-021 12 | 10.161.136.20 kubernetes-node-022 13 | ``` 14 | 15 | ``` 16 | sudo ruby /home/ubuntu/contrail-kubernetes/scripts/opencontrail-install/contrail_install.rb --controller kubernetes-master-01 -k -s 17 | ``` 18 | -------------------------------------------------------------------------------- /01_install-contrail/01_contrail-add-kubernetes-node.md: -------------------------------------------------------------------------------- 1 | # Contrail Specific Steps for adding a Kubernetes node 2 | 3 | * Pull the contrail-kubernetes repo 4 | ``` 5 | sudo apt-get install git ruby 6 | git clone https://github.com/Juniper/contrail-kubernetes 7 | ``` 8 | 9 | * Clean up the nat table 10 | ``` 11 | sudo iptables -F -t nat 12 | ``` 13 | 14 | # Make sure all the nodes are in /etc/hosts 15 | ``` 16 | 10.161.136.17 kubernetes-master-01 17 | 10.161.136.19 kubernetes-node-021 18 | 10.161.136.20 kubernetes-node-022 19 | ``` 20 | * Set ubuntu password to suit the command below or get ssh keys sorted out 21 | * Confirm that this works -- sudo sshpass -p ubuntu ssh -t ubuntu@kubernetes-master-01 date 22 | 23 | ``` 24 | sudo ruby /home/ubuntu/contrail-kubernetes/scripts/opencontrail-install/contrail_install.rb -I eth1 -k -c kubernetes-master-01 -r compute -s 25 | 26 | mkdir -p /var/log/kubernetes 27 | ``` 28 | 29 | * Turn off checksumming on the data vlan interfaces 30 | ``` 31 | ethtool -K eth1 tx off 32 | ifconfig eth1 mtu 1460 33 | ``` 34 | 35 | -------------------------------------------------------------------------------- /01_install-contrail/02_build-kube-network-manager.md: -------------------------------------------------------------------------------- 1 | # Build kube-network-manager 2 | 3 | kube-network-manager will be built and run on the contrail-controller by default. If the k8s-master and contrail-controller are colocated, no further changes required. 4 | 5 | ``` 6 | nohup /home/ubuntu/contrail/kube-network-manager --master=http://127.0.0.1:8080 -- --contrail_api=127.0.0.1 --public_net="10.161.132.0/22" --portal_net="10.254.0.0/16" --private_net="10.0.0.0/16" 2>&1 > /var/log/contrail/kube-network-manager.log 7 | ubuntu@contrail-controller-01:~$ nohup: ignoring input and redirecting stderr to stdout 8 | nohup: ignoring input and redirecting stderr to stdout 9 | ``` 10 | -------------------------------------------------------------------------------- /01_install-contrail/03_contrail-add-static-route.md: -------------------------------------------------------------------------------- 1 | # Add Static route 2 | 3 | If you're running OpenContrail for you OpenStack overlay network you add a static route as follows. This is required for external access. 4 | 5 | This statically routes a block down a given Network Port UUID. This is to route traffic to be picked up by a vrouter gateway. 6 | 7 | On the underlay contrail-controller. Do the following. 8 | 9 | ``` 10 | python interface-route.py add 10.161.132.0/22 11 | ``` 12 | 13 | Confirm it worked by checking the vrf on the MX or running the following. Find the network port UUID and look for the static_route_list 14 | 15 | ``` 16 | http://:8085/Snh_ItfReq?name= 17 | ``` 18 | -------------------------------------------------------------------------------- /01_install-contrail/04_kubernetes-add-vrouter-gateway.md: -------------------------------------------------------------------------------- 1 | # Adding a Gateway to a given vrouter 2 | 3 | In this example we are going to route the prefix 10.161.132.0/22 4 | ``` 5 | Add the following to /etc/contrail/contrail-vrouter-agent.conf 6 | 7 | [GATEWAY-0] 8 | # Name of the routing_instance for which the gateway is being configured 9 | routing_instance=default-domain:default-project:Public:Public 10 | 11 | # Gateway interface name 12 | interface=vgw 13 | 14 | # Virtual network ip blocks for which gateway service is required. Each IP 15 | # block is represented as ip/prefix. Multiple IP blocks are represented by 16 | # separating each with a space 17 | ip_blocks=10.161.132.0/22 18 | ``` 19 | 20 | ip-up script for the gateway interface: 21 | 22 | ``` 23 | ip link add vgw type vhost 24 | ip link set vgw address 00:00:5e:00:01:00 25 | ip link set vgw up 26 | ip route add 10.161.132.0/22 dev vgw 27 | 28 | service contrail-vrouter-agent restart 29 | ``` 30 | -------------------------------------------------------------------------------- /01_install-contrail/05_add_static_route_on_nodes_not_running_vgw.md: -------------------------------------------------------------------------------- 1 | # Adding static route to external block on nodes not running the vgw 2 | 3 | In this example we have a single node running the vrouter vgw supporting external access to Kubernetes. On subsequent node we need to route the external block via the data network interface on the node running the vgw 4 | ``` 5 | ip route add 10.161.132.0/22 via 10.161.136.19 6 | ``` 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kubernetes with Contrail 2 | 3 | Build details for installation of Kubernetes cluster with OpenContrail 4 | 5 | * Network Diagram 6 | ![Network Diagram](https://raw.githubusercontent.com/lachie83/kubernetes-with-contrail/master/diagrams/k8s-contrail-logical-diagram.png) 7 | 8 | Demo 9 | * http://youtu.be/P3dpfvdkGJ0 10 | 11 | Tested Examples 12 | 13 | * DNS service 14 | * Multi-node applications using a single network namespace 15 | * Multi-namespace support 16 | * Network multi-tenancy using namespaces 17 | 18 | Referenced Repos 19 | 20 | * https://github.com/GoogleCloudPlatform/kubernetes 21 | * https://github.com/Juniper/contrail-kubernetes 22 | * https://github.com/openstack/murano-apps/tree/master/Docker/Kubernetes/KubernetesCluster 23 | 24 | Useful Blogs 25 | 26 | * https://pedrormarques.wordpress.com/2015/07/14/kubernetes-networking-with-opencontrail/ 27 | * http://www.opencontrail.org/opencontrail-kubernetes-integration/ 28 | -------------------------------------------------------------------------------- /addons/README.md: -------------------------------------------------------------------------------- 1 | # Addons 2 | 3 | These are the dns and kube-ui addons from the kubernetes repo modified for use with contrail. 4 | -------------------------------------------------------------------------------- /addons/dns/skydns-rc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ReplicationController 3 | metadata: 4 | name: kube-dns-v8 5 | namespace: kube-system 6 | labels: 7 | k8s-app: kube-dns 8 | version: v8 9 | kubernetes.io/cluster-service: "true" 10 | spec: 11 | replicas: 1 12 | selector: 13 | k8s-app: kube-dns 14 | version: v8 15 | template: 16 | metadata: 17 | labels: 18 | k8s-app: kube-dns 19 | version: v8 20 | kubernetes.io/cluster-service: "true" 21 | spec: 22 | containers: 23 | - name: etcd 24 | image: gcr.io/google_containers/etcd:2.0.9 25 | resources: 26 | limits: 27 | cpu: 100m 28 | memory: 50Mi 29 | command: 30 | - /usr/local/bin/etcd 31 | - -data-dir 32 | - /var/etcd/data 33 | - -listen-client-urls 34 | - http://127.0.0.1:2379,http://127.0.0.1:4001 35 | - -advertise-client-urls 36 | - http://127.0.0.1:2379,http://127.0.0.1:4001 37 | - -initial-cluster-token 38 | - skydns-etcd 39 | volumeMounts: 40 | - name: etcd-storage 41 | mountPath: /var/etcd/data 42 | - name: kube2sky 43 | image: gcr.io/google_containers/kube2sky:1.11 44 | resources: 45 | limits: 46 | cpu: 100m 47 | memory: 50Mi 48 | args: 49 | # command = "/kube2sky" 50 | - -domain=kubernetes.io 51 | - -kube_master_url=http://10.254.0.1:8080 52 | - name: skydns 53 | image: gcr.io/google_containers/skydns:2015-03-11-001 54 | resources: 55 | limits: 56 | cpu: 100m 57 | memory: 50Mi 58 | args: 59 | # command = "/skydns" 60 | - -machines=http://localhost:4001 61 | - -addr=0.0.0.0:53 62 | - -domain=kubernetes.io 63 | ports: 64 | - containerPort: 53 65 | name: dns 66 | protocol: UDP 67 | - containerPort: 53 68 | name: dns-tcp 69 | protocol: TCP 70 | # livenessProbe: 71 | # httpGet: 72 | # path: /healthz 73 | # port: 8080 74 | # scheme: HTTP 75 | # initialDelaySeconds: 30 76 | # timeoutSeconds: 5 77 | - name: healthz 78 | image: gcr.io/google_containers/exechealthz:1.0 79 | resources: 80 | limits: 81 | cpu: 10m 82 | memory: 20Mi 83 | args: 84 | - -cmd=nslookup kubernetes.default.svc.kubernetes.io localhost >/dev/null 85 | - -port=8080 86 | ports: 87 | - containerPort: 8080 88 | protocol: TCP 89 | volumes: 90 | - name: etcd-storage 91 | emptyDir: {} 92 | dnsPolicy: Default # Don't use cluster DNS. 93 | -------------------------------------------------------------------------------- /addons/dns/skydns-svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: kube-dns 5 | namespace: kube-system 6 | labels: 7 | k8s-app: kube-dns 8 | kubernetes.io/cluster-service: "true" 9 | kubernetes.io/name: "KubeDNS" 10 | spec: 11 | selector: 12 | k8s-app: kube-dns 13 | clusterIP: 10.254.0.53 14 | deprecatedPublicIPs: ["10.161.132.53"] 15 | ports: 16 | - name: dns 17 | port: 53 18 | protocol: UDP 19 | - name: dns-tcp 20 | port: 53 21 | protocol: TCP 22 | -------------------------------------------------------------------------------- /addons/kube-ui/image/.gitignore: -------------------------------------------------------------------------------- 1 | kube-ui 2 | -------------------------------------------------------------------------------- /addons/kube-ui/image/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Kubernetes Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | FROM scratch 16 | MAINTAINER Tim St. Clair 17 | ADD kube-ui kube-ui 18 | EXPOSE 8080 19 | ENTRYPOINT ["/kube-ui"] 20 | -------------------------------------------------------------------------------- /addons/kube-ui/image/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for the Docker image gcr.io/google_containers/kube-ui 2 | # MAINTAINER: Tim St. Clair 3 | # If you update this image please check the tag value before pushing. 4 | 5 | .PHONY: all container push clean 6 | 7 | # Keep this at dev, so no one accidentally blows away the latest published version. 8 | TAG = dev # current version: v1.1 9 | PREFIX = gcr.io/google_containers 10 | 11 | all: push 12 | 13 | kube-ui: kube-ui.go 14 | CGO_ENABLED=0 GOOS=linux godep go build -a -installsuffix cgo -ldflags '-w' ./kube-ui.go 15 | 16 | container: kube-ui 17 | docker build -t $(PREFIX)/kube-ui:$(TAG) . 18 | 19 | push: container 20 | gcloud docker push $(PREFIX)/kube-ui:$(TAG) 21 | 22 | clean: 23 | rm -f kube-ui 24 | -------------------------------------------------------------------------------- /addons/kube-ui/image/kube-ui.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 The Kubernetes Authors All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // A simple static web server for hosting the Kubernetes cluster UI. 18 | package main 19 | 20 | import ( 21 | "flag" 22 | "fmt" 23 | "mime" 24 | "net/http" 25 | 26 | "github.com/GoogleCloudPlatform/kubernetes/pkg/ui/data/dashboard" 27 | "github.com/golang/glog" 28 | 29 | assetfs "github.com/elazarl/go-bindata-assetfs" 30 | ) 31 | 32 | var ( 33 | port = flag.Int("port", 8080, "Port number to serve at.") 34 | ) 35 | 36 | func main() { 37 | flag.Parse() 38 | 39 | // Send correct mime type for .svg files. TODO: remove when 40 | // https://github.com/golang/go/commit/21e47d831bafb59f22b1ea8098f709677ec8ce33 41 | // makes it into all of our supported go versions. 42 | mime.AddExtensionType(".svg", "image/svg+xml") 43 | 44 | // Expose files in www/ on 45 | fileServer := http.FileServer(&assetfs.AssetFS{ 46 | Asset: dashboard.Asset, 47 | AssetDir: dashboard.AssetDir, 48 | Prefix: "www/app", 49 | }) 50 | http.Handle("/", fileServer) 51 | 52 | // TODO: Add support for serving over TLS. 53 | glog.Fatal(http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", *port), nil)) 54 | } 55 | -------------------------------------------------------------------------------- /addons/kube-ui/kube-system-ns.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: kube-system 5 | -------------------------------------------------------------------------------- /addons/kube-ui/kube-ui-address.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: kube-ui-address 5 | namespace: kube-system 6 | labels: 7 | k8s-app: kube-ui 8 | kubernetes.io/cluster-service: "true" 9 | kubernetes.io/name: "KubeUI" 10 | spec: 11 | selector: 12 | k8s-app: kube-ui 13 | deprecatedPublicIPs: ["10.161.132.18"] 14 | ports: 15 | - port: 80 16 | targetPort: 8080 17 | -------------------------------------------------------------------------------- /addons/kube-ui/kube-ui-endpoint.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Endpoints 3 | metadata: 4 | name: kube-ui 5 | namespace: kube-system 6 | labels: 7 | k8s-app: kube-ui 8 | kubernetes.io/cluster-service: "true" 9 | kubernetes.io/name: "KubeUI" 10 | subsets: 11 | - addresses: 12 | - ip: 10.161.132.18 13 | 14 | ports: 15 | - port: 8080 16 | protocol: TCP 17 | -------------------------------------------------------------------------------- /addons/kube-ui/kube-ui-rc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ReplicationController 3 | metadata: 4 | name: kube-ui-v1 5 | namespace: kube-system 6 | labels: 7 | k8s-app: kube-ui 8 | version: v1 9 | kubernetes.io/cluster-service: "true" 10 | spec: 11 | replicas: 1 12 | selector: 13 | k8s-app: kube-ui 14 | version: v1 15 | template: 16 | metadata: 17 | labels: 18 | k8s-app: kube-ui 19 | version: v1 20 | kubernetes.io/cluster-service: "true" 21 | spec: 22 | containers: 23 | - name: kube-ui 24 | image: gcr.io/google_containers/kube-ui:v1.1 25 | resources: 26 | limits: 27 | cpu: 100m 28 | memory: 50Mi 29 | ports: 30 | - containerPort: 8080 31 | -------------------------------------------------------------------------------- /addons/kube-ui/kube-ui-svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: kube-ui 5 | namespace: kube-system 6 | labels: 7 | k8s-app: kube-ui 8 | kubernetes.io/cluster-service: "true" 9 | kubernetes.io/name: "KubeUI" 10 | spec: 11 | ports: 12 | - port: 80 13 | targetPort: 8080 14 | -------------------------------------------------------------------------------- /diagrams/k8s-contrail-logical-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lachie83/kubernetes-with-contrail/44adac4978b90fb1030e9af71e8ed8499acf6904/diagrams/k8s-contrail-logical-diagram.png -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | These are examples taken from the kubernetes repo and modified to support the contrail plugin. Look for references to type LoadBalancer and the uses label to link namespaces. 4 | -------------------------------------------------------------------------------- /examples/guestbook-go/guestbook-controller.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind":"ReplicationController", 3 | "apiVersion":"v1", 4 | "metadata":{ 5 | "name":"guestbook", 6 | "labels":{ 7 | "app":"guestbook" 8 | } 9 | }, 10 | "spec":{ 11 | "replicas":1, 12 | "selector":{ 13 | "app":"guestbook" 14 | }, 15 | "template":{ 16 | "metadata":{ 17 | "labels":{ 18 | "app":"guestbook", 19 | "name":"guestbook", 20 | "uses":"redis-master" 21 | } 22 | }, 23 | "spec":{ 24 | "containers":[ 25 | { 26 | "name":"guestbook", 27 | "image":"kubernetes/guestbook:v2", 28 | "ports":[ 29 | { 30 | "name":"http-server", 31 | "containerPort":3000 32 | } 33 | ] 34 | } 35 | ] 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/guestbook-go/guestbook-go.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | kubectl create --namespace=guestbook -f guestbook-service.json 4 | kubectl create --namespace=guestbook -f redis-master-service.json 5 | kubectl create --namespace=guestbook -f redis-slave-service.json 6 | kubectl create --namespace=guestbook -f redis-master-controller.json 7 | kubectl create --namespace=guestbook -f redis-slave-controller.json 8 | kubectl create --namespace=guestbook -f guestbook-controller.json 9 | -------------------------------------------------------------------------------- /examples/guestbook-go/guestbook-page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lachie83/kubernetes-with-contrail/44adac4978b90fb1030e9af71e8ed8499acf6904/examples/guestbook-go/guestbook-page.png -------------------------------------------------------------------------------- /examples/guestbook-go/guestbook-service.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind":"Service", 3 | "apiVersion":"v1", 4 | "metadata":{ 5 | "name":"guestbook", 6 | "labels":{ 7 | "app":"guestbook", 8 | "name":"guestbook" 9 | } 10 | }, 11 | "spec":{ 12 | "ports": [ 13 | { 14 | "port":3000, 15 | "targetPort":"http-server" 16 | } 17 | ], 18 | "selector":{ 19 | "app":"guestbook" 20 | }, 21 | "type": "LoadBalancer" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/guestbook-go/redis-master-controller.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind":"ReplicationController", 3 | "apiVersion":"v1", 4 | "id":"redis-master", 5 | "metadata":{ 6 | "name":"redis-master", 7 | "labels":{ 8 | "app":"redis", 9 | "role":"master" 10 | } 11 | }, 12 | "spec":{ 13 | "replicas":1, 14 | "selector":{ 15 | "app":"redis", 16 | "role":"master" 17 | }, 18 | "template":{ 19 | "metadata":{ 20 | "labels":{ 21 | "app":"redis", 22 | "name":"redis-master", 23 | "role":"master" 24 | } 25 | }, 26 | "spec":{ 27 | "containers":[ 28 | { 29 | "name":"redis-master", 30 | "image":"redis", 31 | "ports":[ 32 | { 33 | "name":"redis-server", 34 | "containerPort":6379 35 | } 36 | ] 37 | } 38 | ] 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examples/guestbook-go/redis-master-service.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind":"Service", 3 | "apiVersion":"v1", 4 | "metadata":{ 5 | "name":"redis-master", 6 | "labels":{ 7 | "app":"redis", 8 | "name":"redis-master", 9 | "role":"master" 10 | } 11 | }, 12 | "spec":{ 13 | "ports": [ 14 | { 15 | "port":6379, 16 | "targetPort":"redis-server" 17 | } 18 | ], 19 | "selector":{ 20 | "app":"redis", 21 | "role":"master" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/guestbook-go/redis-slave-controller.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind":"ReplicationController", 3 | "apiVersion":"v1", 4 | "id":"redis-slave", 5 | "metadata":{ 6 | "name":"redis-slave", 7 | "labels":{ 8 | "app":"redis", 9 | "name":"redis", 10 | "role":"slave" 11 | } 12 | }, 13 | "spec":{ 14 | "replicas":2, 15 | "selector":{ 16 | "app":"redis", 17 | "role":"slave" 18 | }, 19 | "template":{ 20 | "metadata":{ 21 | "labels":{ 22 | "app":"redis", 23 | "role":"slave" 24 | } 25 | }, 26 | "spec":{ 27 | "containers":[ 28 | { 29 | "name":"redis-slave", 30 | "image":"kubernetes/redis-slave:v2", 31 | "ports":[ 32 | { 33 | "name":"redis-server", 34 | "containerPort":6379 35 | } 36 | ] 37 | } 38 | ] 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examples/guestbook-go/redis-slave-service.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind":"Service", 3 | "apiVersion":"v1", 4 | "metadata":{ 5 | "name":"redis-slave", 6 | "labels":{ 7 | "app":"redis", 8 | "name":"redis-master", 9 | "role":"slave" 10 | } 11 | }, 12 | "spec":{ 13 | "ports": [ 14 | { 15 | "port":6379, 16 | "targetPort":"redis-server" 17 | } 18 | ], 19 | "selector":{ 20 | "app":"redis", 21 | "role":"slave" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/k8petstore/k8petstore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2015 The Kubernetes Authors All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | echo "WRITING KUBE FILES , will overwrite the jsons, then testing pods. is kube clean ready to go?" 18 | 19 | 20 | #Args below can be overriden when calling from cmd line. 21 | #Just send all the args in order. 22 | #for dev/test you can use: 23 | #kubectl=$GOPATH/src/github.com/GoogleCloudPlatform/kubernetes/cluster/kubectl.sh" 24 | kubectl="kubectl" 25 | VERSION="r.2.8.19" 26 | PUBLIC_IP="10.161.132.17" # ip which we use to access the Web server. 27 | _SECONDS=1000 # number of seconds to measure throughput. 28 | FE="1" # amount of Web server 29 | LG="1" # amount of load generators 30 | SLAVE="1" # amount of redis slaves 31 | TEST="1" # 0 = Dont run tests, 1 = Do run tests. 32 | NS="default" # namespace 33 | 34 | kubectl="${1:-$kubectl}" 35 | VERSION="${2:-$VERSION}" 36 | PUBLIC_IP="${3:-$PUBLIC_IP}" # ip which we use to access the Web server. 37 | _SECONDS="${4:-$_SECONDS}" # number of seconds to measure throughput. 38 | FE="${5:-$FE}" # amount of Web server 39 | LG="${6:-$LG}" # amount of load generators 40 | SLAVE="${7:-$SLAVE}" # amount of redis slaves 41 | TEST="${8:-$TEST}" # 0 = Dont run tests, 1 = Do run tests. 42 | NS="${9:-$NS}" # namespace 43 | 44 | echo "Running w/ args: kubectl $kubectl version $VERSION ip $PUBLIC_IP sec $_SECONDS fe $FE lg $LG slave $SLAVE test $TEST NAMESPACE $NS" 45 | function create { 46 | 47 | cat << EOF > fe-rc.json 48 | { 49 | "kind": "ReplicationController", 50 | "apiVersion": "v1", 51 | "metadata": { 52 | "name": "fectrl", 53 | "labels": {"name": "frontend"} 54 | }, 55 | "spec": { 56 | "replicas": $FE, 57 | "selector": {"name": "frontend"}, 58 | "template": { 59 | "metadata": { 60 | "labels": { 61 | "name": "frontend", 62 | "uses": "redis-master" 63 | } 64 | }, 65 | "spec": { 66 | "containers": [{ 67 | "name": "frontend-go-restapi", 68 | "image": "jayunit100/k8-petstore-web-server:$VERSION" 69 | }] 70 | } 71 | } 72 | } 73 | } 74 | EOF 75 | 76 | cat << EOF > bps-load-gen-rc.json 77 | { 78 | "kind": "ReplicationController", 79 | "apiVersion": "v1", 80 | "metadata": { 81 | "name": "bpsloadgenrc", 82 | "labels": {"name": "bpsLoadGenController"} 83 | }, 84 | "spec": { 85 | "replicas": $LG, 86 | "selector": {"name": "bps"}, 87 | "template": { 88 | "metadata": { 89 | "labels": { 90 | "name": "bps", 91 | "uses": "frontend" 92 | } 93 | }, 94 | "spec": { 95 | "containers": [{ 96 | "name": "bps", 97 | "image": "jayunit100/bigpetstore-load-generator", 98 | "command": ["sh","-c","/opt/PetStoreLoadGenerator-1.0/bin/PetStoreLoadGenerator http://\$FRONTEND_SERVICE_HOST:3000/rpush/k8petstore/ 4 4 1000 123"] 99 | }] 100 | } 101 | } 102 | } 103 | } 104 | EOF 105 | 106 | cat << EOF > fe-s.json 107 | { 108 | "kind": "Service", 109 | "apiVersion": "v1", 110 | "metadata": { 111 | "name": "frontend", 112 | "labels": { 113 | "name": "frontend" 114 | } 115 | }, 116 | "spec": { 117 | "ports": [{ 118 | "port": 3000 119 | }], 120 | "deprecatedPublicIPs":["$PUBLIC_IP","10.1.4.89"], 121 | "selector": { 122 | "name": "frontend" 123 | } 124 | } 125 | } 126 | EOF 127 | 128 | cat << EOF > rm.json 129 | { 130 | "kind": "Pod", 131 | "apiVersion": "v1", 132 | "metadata": { 133 | "name": "redismaster", 134 | "labels": { 135 | "name": "redis-master" 136 | } 137 | }, 138 | "spec": { 139 | "containers": [{ 140 | "name": "master", 141 | "image": "jayunit100/k8-petstore-redis-master:$VERSION", 142 | "ports": [{ 143 | "containerPort": 6379 144 | }] 145 | }] 146 | } 147 | } 148 | EOF 149 | 150 | cat << EOF > rm-s.json 151 | { 152 | "kind": "Service", 153 | "apiVersion": "v1", 154 | "metadata": { 155 | "name": "redismaster", 156 | "labels": { 157 | "name": "redis-master" 158 | } 159 | }, 160 | "spec": { 161 | "ports": [{ 162 | "port": 6379 163 | }], 164 | "selector": { 165 | "name": "redis-master" 166 | } 167 | } 168 | } 169 | EOF 170 | 171 | cat << EOF > rs-s.json 172 | { 173 | "kind": "Service", 174 | "apiVersion": "v1", 175 | "metadata": { 176 | "name": "redisslave", 177 | "labels": { 178 | "name": "redisslave" 179 | } 180 | }, 181 | "spec": { 182 | "ports": [{ 183 | "port": 6379 184 | }], 185 | "selector": { 186 | "name": "redisslave" 187 | } 188 | } 189 | } 190 | EOF 191 | 192 | cat << EOF > slave-rc.json 193 | { 194 | "kind": "ReplicationController", 195 | "apiVersion": "v1", 196 | "metadata": { 197 | "name": "redissc", 198 | "labels": {"name": "redisslave"} 199 | }, 200 | "spec": { 201 | "replicas": $SLAVE, 202 | "selector": {"name": "redisslave"}, 203 | "template": { 204 | "metadata": { 205 | "labels": { 206 | "name": "redisslave", 207 | "uses": "redis-master" 208 | } 209 | }, 210 | "spec": { 211 | "containers": [{ 212 | "name": "slave", 213 | "image": "jayunit100/k8-petstore-redis-slave:$VERSION", 214 | "ports": [{"containerPort": 6379}] 215 | }] 216 | } 217 | } 218 | } 219 | } 220 | EOF 221 | $kubectl create -f rm.json --namespace=$NS 222 | $kubectl create -f rm-s.json --namespace=$NS 223 | sleep 3 # precaution to prevent fe from spinning up too soon. 224 | $kubectl create -f slave-rc.json --namespace=$NS 225 | $kubectl create -f rs-s.json --namespace=$NS 226 | sleep 3 # see above comment. 227 | $kubectl create -f fe-rc.json --namespace=$NS 228 | $kubectl create -f fe-s.json --namespace=$NS 229 | $kubectl create -f bps-load-gen-rc.json --namespace=$NS 230 | } 231 | 232 | function pollfor { 233 | pass_http=0 234 | 235 | ### Test HTTP Server comes up. 236 | for i in `seq 1 150`; 237 | do 238 | ### Just testing that the front end comes up. Not sure how to test total entries etc... (yet) 239 | echo "Trying curl ... $PUBLIC_IP:3000 , attempt $i . expect a few failures while pulling images... " 240 | curl "$PUBLIC_IP:3000" > result 241 | cat result 242 | cat result | grep -q "k8-bps" 243 | if [ $? -eq 0 ]; then 244 | echo "TEST PASSED after $i tries !" 245 | i=1000 246 | break 247 | else 248 | echo "the above RESULT didn't contain target string for trial $i" 249 | fi 250 | sleep 3 251 | done 252 | 253 | if [ $i -eq 1000 ]; then 254 | pass_http=1 255 | fi 256 | 257 | } 258 | 259 | function tests { 260 | pass_load=0 261 | 262 | ### Print statistics of db size, every second, until $SECONDS are up. 263 | for i in `seq 1 $_SECONDS`; 264 | do 265 | echo "curl : $PUBLIC_IP:3000 , $i of $_SECONDS" 266 | curr_cnt="`curl "$PUBLIC_IP:3000/llen"`" 267 | ### Write CSV File of # of trials / total transcations. 268 | echo "$i $curr_cnt" >> result 269 | echo "total transactions so far : $curr_cnt" 270 | sleep 1 271 | done 272 | } 273 | 274 | function warning { 275 | echo "" 276 | echo "THIS SCRIPT IS FOR KUBERNETES < v1." 277 | echo "For LATER VERSIONS, use k8petstore-nodeport.sh or k8petstore-loadbalacer.sh!!!!" 278 | echo "In particular PublicIP is DEPRECATED in post-v1 releases!!!" 279 | echo "" 280 | } 281 | 282 | warning 283 | 284 | create 285 | 286 | pollfor 287 | 288 | if [[ $pass_http -eq 1 ]]; then 289 | echo "Passed..." 290 | else 291 | exit 1 292 | fi 293 | 294 | if [[ $TEST -eq 1 ]]; then 295 | echo "running polling tests now" 296 | tests 297 | fi 298 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | # Tools 2 | 3 | * vrouter-restart.sh 4 | * Vrouter won't reload objects from the contrail if it restarts for any reason. Run this script on a node to reload the config from the controller. 5 | 6 | * purge.sh 7 | * Remove all objects from contrail controller that have been created by kube-network-manager. Effectively a clean slate. 8 | -------------------------------------------------------------------------------- /tools/purge.py: -------------------------------------------------------------------------------- 1 | import vnc_api.vnc_api 2 | 3 | NETWORKS_EXCLUDE=[ 4 | 'default-domain:default-project:__link_local__', 5 | 'default-domain:default-project:default-virtual-network', 6 | 'default-domain:default-project:ip-fabric', 7 | 'default-domain:default-project:Public', 8 | ] 9 | 10 | POLICIES_EXCLUDE=[ 11 | 'default-domain:default-project:default-network-policy', 12 | ] 13 | 14 | def purge(): 15 | client = vnc_api.vnc_api.VncApi() 16 | 17 | list = client.instance_ips_list() 18 | for ref in list['instance-ips']: 19 | print 'delete %s' % (':'.join(ref['fq_name'])) 20 | client.instance_ip_delete(id=ref['uuid']) 21 | 22 | list = client.floating_ips_list() 23 | for ref in list['floating-ips']: 24 | print 'delete %s' % (':'.join(ref['fq_name'])) 25 | client.floating_ip_delete(id=ref['uuid']) 26 | 27 | list = client.virtual_machine_interfaces_list() 28 | for ref in list['virtual-machine-interfaces']: 29 | print 'delete %s' % (':'.join(ref['fq_name'])) 30 | client.virtual_machine_interface_delete(id=ref['uuid']) 31 | 32 | list = client.virtual_machines_list() 33 | for ref in list['virtual-machines']: 34 | print 'delete %s' % (':'.join(ref['fq_name'])) 35 | client.virtual_machine_delete(id=ref['uuid']) 36 | 37 | list = client.floating_ip_pools_list() 38 | for ref in list['floating-ip-pools']: 39 | print 'delete %s' % (':'.join(ref['fq_name'])) 40 | client.floating_ip_pool_delete(id=ref['uuid']) 41 | 42 | list = client.virtual_networks_list() 43 | for ref in list['virtual-networks']: 44 | if ':'.join(ref['fq_name']) in NETWORKS_EXCLUDE: 45 | continue 46 | print 'delete %s' % (':'.join(ref['fq_name'])) 47 | client.virtual_network_delete(id=ref['uuid']) 48 | 49 | list = client.network_policys_list() 50 | for ref in list['network-policys']: 51 | if ':'.join(ref['fq_name']) in POLICIES_EXCLUDE: 52 | continue 53 | print 'delete %s' % (':'.join(ref['fq_name'])) 54 | client.network_policy_delete(id=ref['uuid']) 55 | 56 | 57 | if __name__ == '__main__': 58 | purge() -------------------------------------------------------------------------------- /tools/vrouter-restart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Run the kubebet plugin script for all running containers in the system. 4 | # This can be run as a PostExec script for the vrouter-agent when running 5 | # on a kubernetes node. 6 | # 7 | KUBE_PLUGIN=/usr/libexec/kubernetes/kubelet-plugins/net/exec/opencontrail/opencontrail 8 | 9 | CONTAINERS=$(docker ps | grep -v "/pause" | awk '/[0-9a-z]{12} /{print $1;}') 10 | 11 | for i in $CONTAINERS; do 12 | NAME=$(docker inspect -f '{{.Name}}' $i) 13 | ID=$(docker inspect -f '{{.Id}}' $i) 14 | PODNAME=$(echo $NAME | awk '//{split($0, arr, "_"); print arr[3]}') 15 | NAMESPACE=$(echo $NAME | awk '//{split($0, arr, "_"); print arr[4]}') 16 | $KUBE_PLUGIN setup $NAMESPACE $PODNAME $ID 17 | done 18 | --------------------------------------------------------------------------------