10
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

kind試す

Last updated at Posted at 2019-04-15

いわゆる Kubernetes in Docker。(いわゆるもくそも、だから名前が "kind")

たくさんのクラスタがDockerコンテナ1つで上がる!?感じ。

Learningに使えるかという点で評価してみる。

とりあえずはセットアップと軽めのApp立ち上げ確認。

Pre Setup

  • GCPにて、約メモリ8GB積んだCentOS7 x86_64を用意
  • git
  • docker 18.09.5
  • kubectl 1.14.1

Install Golang

よしなに、

# curl -LO https://dl.google.com/go/go1.12.4.linux-amd64.tar.gz
# tar zxf go1.12.4.linux-amd64.tar.gz 
# mv go /usr/local/bin/

Install kind

# export GOPATH=/usr/local/bin/go/bin
# export PATH=$PATH:$GOPATH
# go get -u sigs.k8s.io/kind

2019/9/4 Update 母艦が Ubuntu 18.04 のとき kind 入れるときに gcc ないと言われたので入れた。

そこそこかかる

2019/7/29 Update インストール部分が以下の様になっていた。

GO111MODULE="on" go get sigs.k8s.io/kind@v0.4.0

# export KINDPATH=/usr/local/bin/go/bin/bin
# export PATH=$PATH:$KINDPATH

# kind create cluster
Creating cluster "kind" ...
 ✓ Ensuring node image (kindest/node:v1.13.4) 🖼
 ✓ Preparing nodes 📦 
 ✓ Creating kubeadm config 📜 
 ✓ Starting control-plane 🕹️ 
Cluster creation complete. You can now use the cluster with:

export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
kubectl cluster-info

そこそこかかる

docker コマンドうってみると・・・・

# docker container ls
CONTAINER ID        IMAGE                  COMMAND                  CREATED              STATUS              PORTS                                  NAMES
c7f23eb8af62        kindest/node:v1.13.4   "/usr/local/bin/entr…"   About a minute ago   Up About a minute   34487/tcp, 127.0.0.1:34487->6443/tcp   kind-control-plane
# kind get kubeconfig-path
/root/.kube/kind-config-kind
# export KUBECONFIG="$(kind get kubeconfig-path)"
# kubectl cluster-info
Kubernetes master is running at https://localhost:37608
KubeDNS is running at https://localhost:37608/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

Wordpressあげてみる

# kubectl get secrets
NAME                    TYPE                                  DATA   AGE
default-token-bkh8n     kubernetes.io/service-account-token   3      36m
mysql-pass-59cdgt95hd   Opaque                                1      14m

# kubectl get pvc
NAME             STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
mysql-pv-claim   Bound    pvc-a8f2baf5-5f5b-11e9-989b-0242a2b9ea4d   20Gi       RWO            standard       15m
wp-pv-claim      Bound    pvc-a8f6eb33-5f5b-11e9-989b-0242a2b9ea4d   20Gi       RWO            standard       15m

# kubectl get pods
NAME                             READY   STATUS    RESTARTS   AGE
wordpress-c6b7fcdd-sfc8d         1/1     Running   0          15m
wordpress-mysql-b4447dd8-xr668   1/1     Running   0          15m

# kubectl get services wordpress
NAME        TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
wordpress   LoadBalancer   10.101.188.12   <pending>     80:32617/TCP   15m

ちゃんとあがっとるので、そとからアクセスできるようにポートフォワード

# kubectl port-forward --address 0.0.0.0 svc/wordpress 80:80

=>ブラウザで確認、ばっちりあがる!

もいっちょクラスタCreate

# kind create cluster --name tk
Creating cluster "tk" ...
 ✓ Ensuring node image (kindest/node:v1.13.4) 🖼
 ✓ Preparing nodes 📦 
 ✓ Creating kubeadm config 📜 
 ✓ Starting control-plane 🕹️ 
Cluster creation complete. You can now use the cluster with:

export KUBECONFIG="$(kind get kubeconfig-path --name="tk")"
kubectl cluster-info

# kind get clusters
tk
kind

追加されてる!ので宛先を変えて、再度Wordpress

# export KUBECONFIG="$(kind get kubeconfig-path --name="tk")"
# kubectl cluster-info
Kubernetes master is running at https://localhost:33629
KubeDNS is running at https://localhost:33629/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

なにがちがうって、さっきとちゃんとMasterの宛先ポートが違う。

同じYAML使ってWordpress上げて、ポートフォワーディングして、ブラウザアクセス。
ばっちりあがった。

が・・・クラスタが2つで外からのアクセスをそれぞれのクラスタのPodにアクセスするようにするのは!?

ちゃんと確認・・・これから。

クラスタ・消す

kind delete cluster --name kind

すぐ消える

Ref

10
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?