Kubernetes : Minikube : インストール2018/10/22 |
Docker コンテナ オーケストレーションシステム Kubernetes のインストールと設定です。
当例では、Minikube をインストールして、シングルノード上の仮想マシン内で Kubernetes クラスターを構成します。
|
[1] | 仮想マシンを利用するため、Minikube でサポートするハイパーバイザーをインストールしておきます。 当例では KVM をインストールして進めます。 その他、VirtualBox, VMware Fusion, HyperKit が利用可能です。 |
root@dlp:~# apt -y install qemu-kvm libvirt-bin virtinst bridge-utils
|
[2] | Kubernetes リポジトリを設定して必要なツールをインストールし、Minikube を起動します。 |
root@dlp:~#
root@dlp:~# apt -y install apt-transport-https curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - OK
root@dlp:~#
root@dlp:~# echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list root@dlp:~# apt update root@dlp:~# apt -y install kubectl
wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -O minikube root@dlp:~# wget https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2 root@dlp:~# chmod 755 minikube docker-machine-driver-kvm2
root@dlp:~#
mv minikube docker-machine-driver-kvm2 /usr/local/bin/
root@dlp:~#
root@dlp:~# minikube version minikube version: v0.30.0 kubectl version -o json { "clientVersion": { "major": "1", "minor": "12", "gitVersion": "v1.12.1", "gitCommit": "4ed3216f3ec431b140b1d899130a69fc671678f4", "gitTreeState": "clean", "buildDate": "2018-10-05T16:46:06Z", "goVersion": "go1.10.4", "compiler": "gc", "platform": "linux/amd64" } } # minikube 起動 root@dlp:~# minikube start --vm-driver kvm2 Starting local Kubernetes v1.10.0 cluster... Starting VM... Downloading Minikube ISO 170.78 MB / 170.78 MB [====================] 100.00% 0s Getting VM IP address... Moving files into cluster... Downloading kubeadm v1.10.0 Downloading kubelet v1.10.0 Finished Downloading kubelet v1.10.0 Finished Downloading kubeadm v1.10.0 Setting up certs... Connecting to cluster... Setting up kubeconfig... Starting cluster components... Kubectl is now configured to use the cluster. Loading cached images from config file. # 状態確認 root@dlp:~# minikube status minikube: Running cluster: Running kubectl: Correctly Configured: pointing to minikube-vm at 192.168.39.30 minikube service list |-------------|----------------------|--------------| | NAMESPACE | NAME | URL | |-------------|----------------------|--------------| | default | kubernetes | No node port | | kube-system | kube-dns | No node port | | kube-system | kubernetes-dashboard | No node port | |-------------|----------------------|--------------|root@dlp:~# minikube docker-env export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://192.168.39.30:2376" export DOCKER_CERT_PATH="/root/.minikube/certs" export DOCKER_API_VERSION="1.35" # Run this command to configure your shell: # eval $(minikube docker-env)root@dlp:~# kubectl cluster-info Kubernetes master is running at https://192.168.39.30:8443 CoreDNS is running at https://192.168.39.30:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.root@dlp:~# kubectl get nodes NAME STATUS ROLES AGE VERSION minikube Ready master 1m v1.10.0 # 仮想マシン [minikube] が起動 root@dlp:~# virsh list Id Name State ---------------------------------------------------- 1 minikube running # 仮想マシンへ SSH アクセス root@dlp:~# minikube ssh _ _ _ _ ( ) ( ) ___ ___ (_) ___ (_)| |/') _ _ | |_ __ /' _ ` _ `\| |/' _ `\| || , < ( ) ( )| '_`\ /'__`\ | ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )( ___/ (_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)
$
$ hostname minikube docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6d389d6d25f6 k8s.gcr.io/k8s-dns-sidecar-amd64 "/sidecar --v=2 --lo…" About a minute ago Up About a minute k8s_sideca... 63d943ec33d2 k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64 "/dnsmasq-nanny -v=2…" About a minute ago Up About a minute k8s_dnsmas... a882858bef21 k8s.gcr.io/kubernetes-dashboard-amd64 "/dashboard --insecu…" About a minute ago Up About a minute k8s_kubern... 5d01b836deaa k8s.gcr.io/coredns "/coredns -conf /etc…" About a minute ago Up About a minute k8s_coredn... aadf06372473 gcr.io/k8s-minikube/storage-provisioner "/storage-provisioner" About a minute ago Up About a minute k8s_storage... 10a96562beae k8s.gcr.io/k8s-dns-kube-dns-amd64 "/kube-dns --domain=…" About a minute ago Up About a minute k8s_kubedn... 8a307aee7262 k8s.gcr.io/kube-proxy-amd64 "/usr/local/bin/kube…" 2 minutes ago Up 2 minutes k8s_kube-p... 097ebdac96eb k8s.gcr.io/pause-amd64:3.1 "/pause" 2 minutes ago Up 2 minutes k8s_POD_cor... 82054756784e k8s.gcr.io/pause-amd64:3.1 "/pause" 2 minutes ago Up 2 minutes k8s_POD_sto... a31e8bdf18bf k8s.gcr.io/pause-amd64:3.1 "/pause" 2 minutes ago Up 2 minutes k8s_POD_kub... fc25cab878b7 k8s.gcr.io/pause-amd64:3.1 "/pause" 2 minutes ago Up 2 minutes k8s_POD_kub... b151bd960243 k8s.gcr.io/pause-amd64:3.1 "/pause" 2 minutes ago Up 2 minutes k8s_POD_kub... c632103f328e k8s.gcr.io/etcd-amd64 "etcd --listen-clien…" 2 minutes ago Up 2 minutes k8s_etcd_e... 21f6970acb9f k8s.gcr.io/kube-apiserver-amd64 "kube-apiserver --ad…" 2 minutes ago Up 2 minutes k8s_kube-a... fe5f2ec07f99 k8s.gcr.io/kube-addon-manager "/opt/kube-addons.sh" 2 minutes ago Up 2 minutes k8s_kube-ad... c87c16624b17 k8s.gcr.io/kube-scheduler-amd64 "kube-scheduler --ad…" 2 minutes ago Up 2 minutes k8s_kube-s... e11030f1359c k8s.gcr.io/kube-controller-manager-amd64 "kube-controller-man…" 3 minutes ago Up 3 minutes k8s_kube-c... 9b749026632d k8s.gcr.io/pause-amd64:3.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kub... 86887c03f302 k8s.gcr.io/pause-amd64:3.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_etc... cd1cd45e82a6 k8s.gcr.io/pause-amd64:3.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kub... f0be87886e27 k8s.gcr.io/pause-amd64:3.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kub... 17bffa0abce5 k8s.gcr.io/pause-amd64:3.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kub...
$
exit
# minikube を停止する場合は以下 root@dlp:~# minikube stop Stopping local Kubernetes cluster... Machine stopped. # minikube 仮想マシンを削除する場合は以下 root@dlp:~# minikube delete Deleting local Kubernetes cluster... Machine deleted. virsh list --all Id Name State ---------------------------------------------------- |
Sponsored Link |