diff --git a/docs/imgs/k8s-active.png b/docs/imgs/k8s-active.png new file mode 100644 index 000000000..1300d9c9a Binary files /dev/null and b/docs/imgs/k8s-active.png differ diff --git a/docs/imgs/k8s-select.png b/docs/imgs/k8s-select.png new file mode 100644 index 000000000..fd9be531c Binary files /dev/null and b/docs/imgs/k8s-select.png differ diff --git a/docs/imgs/k8s-setting.png b/docs/imgs/k8s-setting.png new file mode 100644 index 000000000..b875a63f1 Binary files /dev/null and b/docs/imgs/k8s-setting.png differ diff --git a/docs/setup.md b/docs/setup.md index 85358b464..28a357c09 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -19,6 +19,7 @@ Currently we support Docker Host or Swarm Cluster as Worker Node. More types wil * `Docker Swarm `: [Create a Docker Swarm](https://docs.docker.com/engine/swarm/swarm-tutorial/create-swarm/). * `Kubernetes`: [Kubernetes Setup](https://kubernetes.io/docs/setup/). * `vSphere`: [Setup vSphere as a Worker Node](setup_worker_vsphere.md). +* `Kubernetes Worker`: [Setup Kubernetes as a Worker Node](setup_worker_kubernetes.md.md). * `Ansible`: [Setup Ansible as a Worker Node](setup_worker_ansible.md). ## Special Configuration for Production diff --git a/docs/setup_worker_kubernetes.md b/docs/setup_worker_kubernetes.md new file mode 100644 index 000000000..4965b0969 --- /dev/null +++ b/docs/setup_worker_kubernetes.md @@ -0,0 +1,58 @@ +# Kubernetes type host creation guide + +## Prepare Kubernetes environment + +1. Get started with Kubernetes: [Kubernetes Guide](https://kubernetes.io/docs/user-journeys/users/application-developer/foundational/) + +2. Run `bash cello/scripts/setup_k8s_worker.sh` to set up a Minikube as test environment, the script requires root authority to run. + +## Add Kubernetes type host + +Login to Cello and navigate to the Hosts->;Add Host + +In the "Add a host" page select "Host Type" as KUBERNETES + + ![k8s-select](imgs/k8s-select.png) + +Give a name of the Kubernetes host like "cello-k8s", you can specify a capacity number, this number can be configured later. + + ![k8s-setting](imgs/k8s-setting.png) + +In the Master address field input your Kubernetes master node IP address. Port 443 is used as default and is only supported for now. + +In the "Credential Type" drop down list, select the credential type for Kubernetes host. + +In the "NFS Server Address" input the NFS server address. + +**Action required for NFS Service:** +Cello provides the NFS server by default, please ensure the kubernete cluster could connect to the Cello Host node. + +Use the host node IP as the NFS address. + +In the "Use SSL Verification" checkbox, check it if SSL verification is enabled. + +Optional: in the "Extra Parameters" input the extra Kubernetes parameters in JSON format. + +There are three ways to connect to Kubernetes Host: +#### Username & password + +In the "username" and "password" fields input the username & password with the correct privileges. + +#### Certificate and key + +In the "Certificate content" input ssh certificate content. + +In the "Key content" input ssh key content. + +#### Configuration file + +In the "Configuration content" input configuration file content. + +### Finish Creating Host + +Click Create. You will see the follow page. + + ![vm active](imgs/k8s-active.png) + +This means that the Kubernetes host is ready the new host will be in active state. + diff --git a/docs/tutorial.md b/docs/tutorial.md index 0ddd0de53..3c7d758dd 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -38,6 +38,8 @@ After successful adding, you can find the `docker_host` shown in the Host page, If you are going to create vSphere type host, you can take the steps at the [vSphere type host creation guide](./setup_worker_vsphere.md). +If you are going to create Kubernetes type host, you can take the steps at the [Kubernetes type host creation guide](./setup_worker_kubernetes.md). + ## Create a Chain Now we have the free host in the pool, new chains can be create. diff --git a/scripts/worker_node/setup_k8s_worker_node.sh b/scripts/worker_node/setup_k8s_worker_node.sh index 0cda5eb12..871933abf 100644 --- a/scripts/worker_node/setup_k8s_worker_node.sh +++ b/scripts/worker_node/setup_k8s_worker_node.sh @@ -26,3 +26,26 @@ fi ARCH=x86_64 # TODO: + +# Set up minikube +curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube +curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl + +export MINIKUBE_WANTUPDATENOTIFICATION=false +export MINIKUBE_WANTREPORTERRORPROMPT=false +export MINIKUBE_HOME=$HOME +export CHANGE_MINIKUBE_NONE_USER=true +mkdir -p $HOME/.kube +touch $HOME/.kube/config + +export KUBECONFIG=$HOME/.kube/config +sudo -E ./minikube start --vm-driver=none + +# this for loop waits until kubectl can access the api server that Minikube has created +for i in {1..150}; do # timeout for 5 minutes + ./kubectl get po &> /dev/null + if [ $? -ne 1 ]; then + break + fi + sleep 2 +done