wrider | c1be425 | 2019-11-26 10:13:54 -0500 | [diff] [blame] | 1 | .. This work is licensed under a Creative Commons Attribution 4.0 International License. |
| 2 | .. SPDX-License-Identifier: CC-BY-4.0 |
| 3 | .. ===============LICENSE_START======================================================= |
Lott, Christopher (cl778h) | c22d1ce | 2020-01-20 13:53:43 -0500 | [diff] [blame] | 4 | .. Copyright (C) 2019-2020 AT&T Intellectual Property |
wrider | c1be425 | 2019-11-26 10:13:54 -0500 | [diff] [blame] | 5 | .. =================================================================================== |
Lott, Christopher (cl778h) | c22d1ce | 2020-01-20 13:53:43 -0500 | [diff] [blame] | 6 | .. This documentation file is distributed under the Creative Commons Attribution |
| 7 | .. 4.0 International License (the "License"); you may not use this file except in |
wrider | c1be425 | 2019-11-26 10:13:54 -0500 | [diff] [blame] | 8 | .. compliance with the License. You may obtain a copy of the License at |
| 9 | .. |
| 10 | .. http://creativecommons.org/licenses/by/4.0 |
| 11 | .. |
| 12 | .. This file 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 | .. ===============LICENSE_END========================================================= |
| 17 | |
| 18 | |
wrider | c1be425 | 2019-11-26 10:13:54 -0500 | [diff] [blame] | 19 | Script for Setting Up 1-node Kubernetes Cluster |
| 20 | ----------------------------------------------- |
| 21 | |
Lott, Christopher (cl778h) | cb20033 | 2020-01-20 15:56:57 -0500 | [diff] [blame^] | 22 | The it/dep repo can be used for generating a simple script that can help setting up a |
| 23 | one-node Kubernetes cluster for dev and testing purposes. Related files are under the |
| 24 | **ric-infra/00-Kubernetes** directory. To get started, clone the repository on the |
| 25 | target VM: |
wrider | c1be425 | 2019-11-26 10:13:54 -0500 | [diff] [blame] | 26 | |
Lott, Christopher (cl778h) | cb20033 | 2020-01-20 15:56:57 -0500 | [diff] [blame^] | 27 | :: |
| 28 | |
| 29 | git clone https://gerrit.o-ran-sc.org/r/it/dep |
| 30 | |
wrider | c1be425 | 2019-11-26 10:13:54 -0500 | [diff] [blame] | 31 | |
| 32 | Configurations |
| 33 | -------------- |
| 34 | |
| 35 | The generation of the script reads in the parameters from the following files: |
| 36 | |
Lott, Christopher (cl778h) | cb20033 | 2020-01-20 15:56:57 -0500 | [diff] [blame^] | 37 | - etc/env.rc: Normally no change needed for this file. If where the Kubernetes cluster runs |
| 38 | has special requirements, such as running private Docker registry with self-signed certificates, |
| 39 | or hostnames that can be only resolved via private /etc/hosts entries, such parameters are |
| 40 | entered into this file. |
| 41 | - etc/infra.rc: This file specifies the docker host, Kubernetes, and Kubernetes CNI versions. |
| 42 | If a version is left empty, the installation will use the default version that the OS package |
| 43 | management software would install. |
| 44 | - etc/openstack.rc: If the Kubernetes cluster is deployed on Open Stack VMs, this file specifies |
| 45 | parameters for accessing the APIs of the Open Stack installation. This is not supported in Amber |
| 46 | release yet. |
wrider | c1be425 | 2019-11-26 10:13:54 -0500 | [diff] [blame] | 47 | |
| 48 | |
| 49 | Generating Set-up Script |
| 50 | ------------------------ |
| 51 | |
Lott, Christopher (cl778h) | cb20033 | 2020-01-20 15:56:57 -0500 | [diff] [blame^] | 52 | After the configurations are updated, the following steps will create a script file that can be |
| 53 | used for setting up a one-node Kubernetes cluster. You must run this command on a Linux machine |
| 54 | with the 'envsubst' command installed. |
wrider | c1be425 | 2019-11-26 10:13:54 -0500 | [diff] [blame] | 55 | |
| 56 | :: |
| 57 | |
Lott, Christopher (cl778h) | cb20033 | 2020-01-20 15:56:57 -0500 | [diff] [blame^] | 58 | % cd bin |
| 59 | % ./gen-cloud-init.sh |
wrider | c1be425 | 2019-11-26 10:13:54 -0500 | [diff] [blame] | 60 | |
Lott, Christopher (cl778h) | c22d1ce | 2020-01-20 13:53:43 -0500 | [diff] [blame] | 61 | A file named **k8s-1node-cloud-init.sh** would now appear under the bin directory. |
wrider | c1be425 | 2019-11-26 10:13:54 -0500 | [diff] [blame] | 62 | |
| 63 | |
| 64 | Setting up Kubernetes Cluster |
| 65 | ----------------------------- |
| 66 | |
Lott, Christopher (cl778h) | c22d1ce | 2020-01-20 13:53:43 -0500 | [diff] [blame] | 67 | The new **k8s-1node-cloud-init.sh** file is now ready for setting up the Kubernetes cluster. |
wrider | c1be425 | 2019-11-26 10:13:54 -0500 | [diff] [blame] | 68 | |
Lott, Christopher (cl778h) | cb20033 | 2020-01-20 15:56:57 -0500 | [diff] [blame^] | 69 | It can be run from a root shell of an existing Ubuntu 16.04 or 18.04 VM. Running this script |
| 70 | will replace any existing installation of Docker host, Kubernetes, and Helm on the VM. The |
| 71 | script will reboot the machine upon successful completion. Run the script like this: |
wrider | c1be425 | 2019-11-26 10:13:54 -0500 | [diff] [blame] | 72 | |
Lott, Christopher (cl778h) | cb20033 | 2020-01-20 15:56:57 -0500 | [diff] [blame^] | 73 | :: |
wrider | c1be425 | 2019-11-26 10:13:54 -0500 | [diff] [blame] | 74 | |
Lott, Christopher (cl778h) | cb20033 | 2020-01-20 15:56:57 -0500 | [diff] [blame^] | 75 | % sudo -i |
| 76 | # ./k8s-1node-cloud-init.sh |
| 77 | |
| 78 | This script can also be used as the user-data (a.k.a. cloud-init script) supplied to Open Stack |
| 79 | when launching a new Ubuntu 16.04 or 18.04 VM. |
| 80 | |
| 81 | Upon successful execution of the script and reboot of the machine, when queried in a root shell |
| 82 | with the kubectl command the VM should display information similar to below: |
wrider | c1be425 | 2019-11-26 10:13:54 -0500 | [diff] [blame] | 83 | |
| 84 | :: |
| 85 | |
| 86 | # kubectl get pods --all-namespaces |
| 87 | NAMESPACE NAME READY STATUS RESTARTS AGE |
| 88 | kube-system coredns-5644d7b6d9-4gjp5 1/1 Running 0 103m |
| 89 | kube-system coredns-5644d7b6d9-pvsj8 1/1 Running 0 103m |
| 90 | kube-system etcd-ljitest 1/1 Running 0 102m |
| 91 | kube-system kube-apiserver-ljitest 1/1 Running 0 103m |
| 92 | kube-system kube-controller-manager-ljitest 1/1 Running 0 102m |
| 93 | kube-system kube-flannel-ds-amd64-nvjmq 1/1 Running 0 103m |
| 94 | kube-system kube-proxy-867v5 1/1 Running 0 103m |
| 95 | kube-system kube-scheduler-ljitest 1/1 Running 0 102m |
| 96 | kube-system tiller-deploy-68bf6dff8f-6pwvc 1/1 Running 0 102m |