Skip to content

Commit

Permalink
[CE-384] User guide for kubernetes agent
Browse files Browse the repository at this point in the history
1. Introduce the creation of k8s type host.
2. Provide script to setup a minikube test environment.

Change-Id: Iafc0a01dd4e5ddf03a1cd42e76b2992dc1d4b512
Signed-off-by: luke <[email protected]>
  • Loading branch information
jiahaoc1993 committed Jul 8, 2018
1 parent f0fdf5e commit 9c3d2ea
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 0 deletions.
Binary file added docs/imgs/k8s-active.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/imgs/k8s-select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/imgs/k8s-setting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 58 additions & 0 deletions docs/setup_worker_kubernetes.md
Original file line number Diff line number Diff line change
@@ -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.

2 changes: 2 additions & 0 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 23 additions & 0 deletions scripts/worker_node/setup_k8s_worker_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9c3d2ea

Please sign in to comment.