セットアップ

Kubernetes v1.14 のドキュメントは積極的にメンテナンスされていません。現在表示されているバージョンはスナップショットです。最新のドキュメントはこちらです: 最新バージョン

Edit This Page

CenturyLink Cloud上でKubernetesを動かす

{: toc}

These scripts handle the creation, deletion and expansion of Kubernetes clusters on CenturyLink Cloud.

You can accomplish all these tasks with a single command. We have made the Ansible playbooks used to perform these tasks available here.

ヘルプの検索

If you run into any problems or want help with anything, we are here to help. Reach out to use via any of the following ways:

仮想マシンもしくは物理サーバーのクラスター、その選択

必要条件

The requirements to run this script are:

スクリプトのインストール

After you have all the requirements met, please follow these instructions to install this script.

1) Clone this repository and cd into it.

git clone https://github.com/CenturyLinkCloud/adm-kubernetes-on-clc

2) Install all requirements, including

3) Create the credentials file from the template and use it to set your ENV variables

cp ansible/credentials.sh.template ansible/credentials.sh
vi ansible/credentials.sh
source ansible/credentials.sh

4) Grant your machine access to the CenturyLink Cloud network by using a VM inside the network or configuring a VPN connection to the CenturyLink Cloud network.

スクリプトのインストールの例: Ububtu 14の手順

If you use an ubuntu 14, for your convenience we have provided a step by step guide to install the requirements and install the script.

# system
apt-get update
apt-get install -y git python python-crypto
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py

# installing this repository
mkdir -p ~home/k8s-on-clc
cd ~home/k8s-on-clc
git clone https://github.com/CenturyLinkCloud/adm-kubernetes-on-clc.git
cd adm-kubernetes-on-clc/
pip install -r requirements.txt

# getting started
cd ansible
cp credentials.sh.template credentials.sh; vi credentials.sh
source credentials.sh

クラスターの作成

To create a new Kubernetes cluster, simply run the kube-up.sh script. A complete list of script options and some examples are listed below.

CLC_CLUSTER_NAME=[name of kubernetes cluster]
cd ./adm-kubernetes-on-clc
bash kube-up.sh -c="$CLC_CLUSTER_NAME"

It takes about 15 minutes to create the cluster. Once the script completes, it will output some commands that will help you setup kubectl on your machine to point to the new cluster.

When the cluster creation is complete, the configuration files for it are stored locally on your administrative host, in the following directory

> CLC_CLUSTER_HOME=$HOME/.clc_kube/$CLC_CLUSTER_NAME/

クラスターの作成: スクリプトのオプション

Usage: kube-up.sh [OPTIONS]
Create servers in the CenturyLinkCloud environment and initialize a Kubernetes cluster
Environment variables CLC_V2_API_USERNAME and CLC_V2_API_PASSWD must be set in
order to access the CenturyLinkCloud API

All options (both short and long form) require arguments, and must include "="
between option name and option value.

     -h (--help)                   display this help and exit
     -c= (--clc_cluster_name=)     set the name of the cluster, as used in CLC group names
     -t= (--minion_type=)          standard -> VM (default), bareMetal -> physical]
     -d= (--datacenter=)           VA1 (default)
     -m= (--minion_count=)         number of kubernetes minion nodes
     -mem= (--vm_memory=)          number of GB ram for each minion
     -cpu= (--vm_cpu=)             number of virtual cps for each minion node
     -phyid= (--server_conf_id=)   physical server configuration id, one of
                                      physical_server_20_core_conf_id
                                      physical_server_12_core_conf_id
                                      physical_server_4_core_conf_id (default)
     -etcd_separate_cluster=yes    create a separate cluster of three etcd nodes,
                                   otherwise run etcd on the master node

クラスターの拡張

To expand an existing Kubernetes cluster, run the add-kube-node.sh script. A complete list of script options and some examples are listed below. This script must be run from the same host that created the cluster (or a host that has the cluster artifact files stored in ~/.clc_kube/$cluster_name).

cd ./adm-kubernetes-on-clc
bash add-kube-node.sh -c="name_of_kubernetes_cluster" -m=2

クラスターの拡張: スクリプトのオプション

Usage: add-kube-node.sh [OPTIONS]
Create servers in the CenturyLinkCloud environment and add to an
existing CLC kubernetes cluster

Environment variables CLC_V2_API_USERNAME and CLC_V2_API_PASSWD must be set in
order to access the CenturyLinkCloud API

     -h (--help)                   display this help and exit
     -c= (--clc_cluster_name=)     set the name of the cluster, as used in CLC group names
     -m= (--minion_count=)         number of kubernetes minion nodes to add

クラスターの削除

There are two ways to delete an existing cluster:

1) Use our python script:

python delete_cluster.py --cluster=clc_cluster_name --datacenter=DC1

2) Use the CenturyLink Cloud UI. To delete a cluster, log into the CenturyLink Cloud control portal and delete the parent server group that contains the Kubernetes Cluster. We hope to add a scripted option to do this soon.

Create a cluster with name of k8s_1, 1 master node and 3 worker minions (on physical machines), in VA1

bash kube-up.sh --clc_cluster_name=k8s_1 --minion_type=bareMetal --minion_count=3 --datacenter=VA1

Create a cluster with name of k8s_2, an ha etcd cluster on 3 VMs and 6 worker minions (on VMs), in VA1

bash kube-up.sh --clc_cluster_name=k8s_2 --minion_type=standard --minion_count=6 --datacenter=VA1 --etcd_separate_cluster=yes

Create a cluster with name of k8s_3, 1 master node, and 10 worker minions (on VMs) with higher mem/cpu, in UC1:

bash kube-up.sh --clc_cluster_name=k8s_3 --minion_type=standard --minion_count=10 --datacenter=VA1 -mem=6 -cpu=4

クラスターの機能とアーキテクチャ

We configure the Kubernetes cluster with the following features:

We use the following to create the Kubernetes cluster:

任意のアドオン

クラスターの管理

The most widely used tool for managing a Kubernetes cluster is the command-line utility kubectl. If you do not already have a copy of this binary on your administrative machine, you may run the script install_kubectl.sh which will download it and install it in /usr/bin/local.

The script requires that the environment variable CLC_CLUSTER_NAME be defined

authentication certificates for the particular cluster.  The configuration file is
written to the  ```${CLC_CLUSTER_HOME}/kube``` directory

shell export KUBECONFIG=${CLC_CLUSTER_HOME}/kube/config kubectl version kubectl cluster-info


### プログラムでクラスターへアクセス

It's possible to use the locally stored client certificates to access the apiserver. For example, you may want to use any of the [Kubernetes API client libraries](/docs/reference/using-api/client-libraries/) to program against your Kubernetes cluster in the programming language of your choice. 

To demonstrate how to use these locally stored certificates, we provide the following example of using ```curl``` to communicate to the master apiserver via https:

shell curl
–cacert ${CLC_CLUSTER_HOME}/pki/ca.crt
–key ${CLC_CLUSTER_HOME}/pki/kubecfg.key
–cert ${CLC_CLUSTER_HOME}/pki/kubecfg.crt https://${MASTER_IP}:6443


But please note, this *does not* work out of the box with the ```curl``` binary
distributed with macOS.

### ブラウザーを使ったクラスターへのアクセス

We install [the kubernetes dashboard](/docs/tasks/web-ui-dashboard/). When you
create a cluster, the script should output URLs for these interfaces like this:

kubernetes-dashboard is running at ```https://${MASTER_IP}:6443/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy```.

Note on Authentication to the UIs: The cluster is set up to use basic
authentication for the user _admin_.   Hitting the url at

https://${MASTER_IP}:6443``` will require accepting the self-signed certificate from the apiserver, and then presenting the admin password written to file at:

### 設定ファイル

Various configuration files are written into the home directory *CLC_CLUSTER_HOME* under

.clc_kube/${CLC_CLUSTER_NAME}``` in several subdirectories. You can use these files to access the cluster from machines other than where you created the cluster from.

kubectl get nodes kubectl get –all-namespaces pods kubectl get –all-namespaces services kubectl get –namespace=kube-system replicationcontrollers


The Kubernetes API server exposes services on web URLs, which are protected by requiring
client certificates.  If you run a kubectl proxy locally, ```kubectl``` will provide
the necessary certificates and serve locally over http.

shell kubectl proxy -p 8001 ```

Then, you can access urls like http://127.0.0.1:8001/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy/ without the need for client certificates in your browser.

These are the known items that don’t work on CenturyLink cloud but do work on other cloud providers:

Ansibleのファイル

If you want more information about our Ansible files, please read this file

参考文献

Please see the Kubernetes docs for more details on administering and using a Kubernetes cluster.

フィードバック