minikubeでcreate deployment

$ sudo kubectl get nodes
$ sudo kubectl describe nodes ubuntu-bionic
$ sudo kubectl proxy
Starting to serve on 127.0.0.1:8001

※kubectlはクラスタのマスターノード上で実行される

$ sudo kubectl get pods -o wide
No resources found in default namespace.
$ sudo kubectl get pods -o json
{
“apiVersion”: “v1”,
“items”: [],
“kind”: “List”,
“metadata”: {
“resourceVersion”: “”,
“selfLink”: “”
}
}

### hello-minikube
// pod, deployment作成
$ kubectl run hello-minikube –image=k8s.gcr.io/echoserver:1.4 –port=8080
// get deployment
$ sudo kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGE
hello-minikube 0/1 1 0 2m
// serviceを使う
$ sudo kubectl expose deployment hello-minikube –type=NodePort
service/hello-minikube exposed
$ sudo minikube service hello-minikube –url
$ curl http://192.168.33.10:30835
CLIENT VALUES:
client_address=172.17.0.1
command=GET
real path=/
query=nil
request_version=1.1
request_uri=http://192.168.33.10:8080/

SERVER VALUES:
server_version=nginx: 1.10.0 – lua: 10001

HEADERS RECEIVED:
accept=*/*
host=192.168.33.10:30835
user-agent=curl/7.58.0
BODY:
-no body in request-v

### hello-node
$ sudo kubectl create deployment hello-node –image=gcr.io/hello-minikube-zero-install/hello-node

$ sudo kubectl get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
hello-minikube 1/1 1 1 38m
hello-node 1/1 1 1 21m

$ sudo kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-minikube-75cb6dd856-8rxx7 1/1 Running 0 38m
hello-node-7676b5fb8d-hdj6d 1/1 Running 0 21m

$ kubectl expose deployment hello-node –type=LoadBalancer –port=8080
$ sudo kubectl get services
$ curl http://192.168.33.10:32720
Hello World!

kubectl createでDockerコンテナを使用してpodを作成する
Deploymentを作成するとDeployment、replicaset, Podが作られる

k8sのアーキテクチャ

マスターコンポーネントでnodeを制御している
コンテナはnodeのpodの中で実行される
minikubeではマスターとウォーカーは同じサーバだが、k8sでは別サーバ

ロードバランサの役割もk8sでやってしまうイメージか。
create deploymentでGCPからimageをpullしているけど、実務上ではDockerfileでコンテナの仕様を書いていくと思うんだが、その場合のnode、podはどうやって作成して関連付けていくのか良く解らんな。サンプルじゃなくて、実際にアプリを作らないときついか?

18.04(bionic)でminikube🐳

$ uname -a
Linux ubuntu-bionic 4.15.0-91-generic #92-Ubuntu SMP Fri Feb 28 11:09:48 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ git –version
git version 2.17.1

### kubectl install
$ sudo snap install kubectl –classic
$ kubectl version
Client Version: version.Info{Major:”1″, Minor:”17″, GitVersion:”v1.17.3″, GitCommit:”06ad960bfd03b39c8310aaf92d1e7c12ce618213″, GitTreeState:”clean”, BuildDate:”2020-02-12T13:43:46Z”, GoVersion:”go1.13.7″, Compiler:”gc”, Platform:”linux/amd64″}

### Docker install
$ sudo apt-get update
$ sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
$ sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”
$ sudo apt-get update
$ sudo apt-get install -y docker-ce docker-ce-cli containerd.io
$ sudo docker –version
Docker version 19.03.8, build afacb8b7f0

### docker-compose
$ sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
$ docker-compose –version
docker-compose version 1.21.2, build a133471

### minikube
$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
$ chmod +x minikube
$ sudo cp minikube /usr/local/bin
$ sudo minikube start –vm-driver=none
$ sudo minikube start –vm-driver=none
$ sudo minikube status
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
$ sudo kubectl get nodes
NAME STATUS ROLES AGE VERSION
ubuntu-bionic Ready master 16m v1.17.3

なんか良く解らないがminikubeが動いているように見える🐳
nodeがminikubeでなく、ubuntu-bionicになってるけど、合ってるのだろうか?

ubuntu14.04(trusty)でminikubeを起動しようと思ったら

ubuntuでkubernetesを学びたい🐳
docker, docker-composeはインストール済

$ uname -a
Linux vagrant-ubuntu-trusty-64 4.4.0-148-generic #174~14.04.1-Ubuntu SMP Thu May 9 08:17:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
$ docker –version
Docker version 18.06.3-ce, build d7080c1

1. kubectlインストール
2. Minikubeインストール

### kubectlのインストール
k8s公式を参考にする
install-kubectl
$ sudo apt-get update && sudo apt-get install -y apt-transport-https
$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add –
$ echo “deb https://apt.kubernetes.io/ kubernetes-xenial main” | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
$ sudo apt-get update
$ sudo apt-get install -y kubectl
$ kubectl version
Client Version: version.Info{Major:”1″, Minor:”17″, GitVersion:”v1.17.4″, GitCommit:”8d8aa39598534325ad77120c120a22b3a990b5ea”, GitTreeState:”clean”, BuildDate:”2020-03-12T21:03:42Z”, GoVersion:”go1.13.8″, Compiler:”gc”, Platform:”linux/amd64″}

### minikubeインストール
$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
$ sudo chmod +x minikube
$ sudo cp minikube /usr/local/bin
$ sudo minikube start –vm-driver=none
* minikube v1.8.2 on Ubuntu 14.04 (vbox/amd64)
* Using the none driver based on user configuration

! ‘none’ driver reported an issue: exec: “systemctl”: executable file not found in $PATH
* Suggestion: Use a systemd based Linux distribution
* Documentation: https://minikube.sigs.k8s.io/docs/reference/drivers/none/

X none does not appear to be installed

あ、14.04は古いのか。サポートも終了しているみたいだし、18.04でやり直そう。。

$ vagrant ssh
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-91-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

System information as of Sat Mar 21 05:59:25 UTC 2020

System load: 0.01 Processes: 109
Usage of /: 12.3% of 9.63GB Users logged in: 0
Memory usage: 16% IP address for enp0s3: 10.0.2.15
Swap usage: 0% IP address for enp0s8: 192.168.33.10

0 packages can be updated.
0 updates are security updates.