Install and start Minikube
Install the Minikube
1
2
|
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64
sudo install minikube-darwin-amd64 /usr/local/bin/minikube
|
Start minikube cluster and Check the status
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
{seilylook} ๐ minikube start
๐ Darwin 14.6.1 (arm64) ์ minikube v1.33.0
โจ ๊ธฐ์กด ํ๋กํ์ ๊ธฐ๋ฐํ์ฌ docker ๋๋ผ์ด๋ฒ๋ฅผ ์ฌ์ฉํ๋ ์ค
๐ Starting "minikube" primary control-plane node in "minikube" cluster
๐ Pulling base image v0.0.43 ...
๐คท docker "minikube" container is missing, will recreate.
๐ฅ Creating docker container (CPUs=2, Memory=4600MB) ...
๐ณ ์ฟ ๋ฒ๋คํฐ์ค v1.30.0 ์ Docker 26.0.1 ๋ฐํ์์ผ๋ก ์ค์นํ๋ ์ค
โช ์ธ์ฆ์ ๋ฐ ํค๋ฅผ ์์ฑํ๋ ์ค ...
โช ์ปจํธ๋กค ํ๋ ์ธ์ ๋ถํ
ํ๋ ์ค ...
โช RBAC ๊ท์น์ ๊ตฌ์ฑํ๋ ์ค ...
๐ bridge CNI (Container Networking Interface) ๋ฅผ ๊ตฌ์ฑํ๋ ์ค ...
๐ Kubernetes ๊ตฌ์ฑ ์์๋ฅผ ํ์ธ...
โช Using image gcr.io/k8s-minikube/storage-provisioner:v5
๐ ์ ๋์จ ํ์ฑํ : storage-provisioner, default-storageclass
๐ ๋๋ฌ์ต๋๋ค! kubectl์ด "minikube" ํด๋ฌ์คํฐ์ "default" ๋ค์์คํ์ด์ค๋ฅผ ๊ธฐ๋ณธ์ ์ผ๋ก ์ฌ์ฉํ๋๋ก ๊ตฌ์ฑ๋์์ต๋๋ค.
{seilylook} ๐ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
|
Create 3 Nodes in Cluster
Command for create nodes
1
|
minikube start --nodes <NUMBER_OF_NODES> -p <CLUSTER_NAME>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{seilylook} ๐ minikube start --nodes 3 -p k8scluster
๐ [k8scluster] Darwin 14.6.1 (arm64) ์ minikube v1.33.0
โจ ์๋์ ์ผ๋ก docker ๋๋ผ์ด๋ฒ๊ฐ ์ ํ๋์์ต๋๋ค
๐ Using Docker Desktop driver with root privileges
๐ Starting "k8scluster" primary control-plane node in "k8scluster" cluster
๐ Pulling base image v0.0.43 ...
๐ฅ Creating docker container (CPUs=2, Memory=2200MB) ...
๐ณ ์ฟ ๋ฒ๋คํฐ์ค v1.30.0 ์ Docker 26.0.1 ๋ฐํ์์ผ๋ก ์ค์นํ๋ ์ค
โช ์ธ์ฆ์ ๋ฐ ํค๋ฅผ ์์ฑํ๋ ์ค ...
โช ์ปจํธ๋กค ํ๋ ์ธ์ ๋ถํ
ํ๋ ์ค ...
โช RBAC ๊ท์น์ ๊ตฌ์ฑํ๋ ์ค ...
๐ CNI (Container Networking Interface) ๋ฅผ ๊ตฌ์ฑํ๋ ์ค ...
๐ Kubernetes ๊ตฌ์ฑ ์์๋ฅผ ํ์ธ...
โช Using image gcr.io/k8s-minikube/storage-provisioner:v5
๐ ์ ๋์จ ํ์ฑํ : storage-provisioner, default-storageclass
๐ Starting "k8scluster-m02" worker node in "k8scluster" cluster
๐ Pulling base image v0.0.43 ...
๐ฅ Creating docker container (CPUs=2, Memory=2200MB) ...
๐ ๋คํธ์ํฌ ์ต์
์ ์ฐพ์์ต๋๋ค
โช NO_PROXY=192.168.58.2
๐ณ ์ฟ ๋ฒ๋คํฐ์ค v1.30.0 ์ Docker 26.0.1 ๋ฐํ์์ผ๋ก ์ค์นํ๋ ์ค
โช env NO_PROXY=192.168.58.2
๐ Kubernetes ๊ตฌ์ฑ ์์๋ฅผ ํ์ธ...
๐ Starting "k8scluster-m03" worker node in "k8scluster" cluster
๐ Pulling base image v0.0.43 ...
๐ฅ Creating docker container (CPUs=2, Memory=2200MB) ...
๐ ๋คํธ์ํฌ ์ต์
์ ์ฐพ์์ต๋๋ค
โช NO_PROXY=192.168.58.2,192.168.58.3
๐ณ ์ฟ ๋ฒ๋คํฐ์ค v1.30.0 ์ Docker 26.0.1 ๋ฐํ์์ผ๋ก ์ค์นํ๋ ์ค
โช env NO_PROXY=192.168.58.2
โช env NO_PROXY=192.168.58.2,192.168.58.3
๐ Kubernetes ๊ตฌ์ฑ ์์๋ฅผ ํ์ธ...
๐ ๋๋ฌ์ต๋๋ค! kubectl์ด "k8scluster" ํด๋ฌ์คํฐ์ "default" ๋ค์์คํ์ด์ค๋ฅผ ๊ธฐ๋ณธ์ ์ผ๋ก ์ฌ์ฉํ๋๋ก ๊ตฌ์ฑ๋์์ต๋๋ค.
{seilylook} ๐ kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8scluster Ready control-plane 9m30s v1.30.0
k8scluster-m02 Ready <none> 9m10s v1.30.0
k8scluster-m03 Ready <none> 9m2s v1.30.0
|
Label Nodes
When deploying Redis and Apache Pods, I don’t want them to deploy to own control-plane
.
To do this, I can use labels, taints, affinity.
In this tutorial, I’ll use labels.
KEY | Value
node-role.kubernetes.io/worker: worker
1
|
kubectl label node <NODE_NAME> node-role.kubernetes.io/worker=worker
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
{seilylook} ๐ ๎ฐ ~/Development/Devlog ๎ฐ ๎ main ยฑ ๎ฐ kubectl label node k8scluster-m02 node-role.kubernetes.io/worker=worker
node/k8scluster-m02 labeled
{seilylook} ๐ ๎ฐ ~/Development/Devlog ๎ฐ ๎ main ยฑ ๎ฐ kubectl label node k8scluster-m03 node-role.kubernetes.io/worker=worker
node/k8scluster-m03 labeled
{seilylook} ๐ ๎ฐ ~/Development/Devlog ๎ฐ ๎ main ยฑ ๎ฐ kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8scluster Ready control-plane 16m v1.30.0
k8scluster-m02 Ready worker 16m v1.30.0
k8scluster-m03 Ready worker 16m v1.30.0
{seilylook} ๐ ๎ฐ ~/Development/Devlog ๎ฐ ๎ main ยฑ ๎ฐ kubectl describe node k8scluster-m02
Name: k8scluster-m02
Roles: worker
Labels: beta.kubernetes.io/arch=arm64
beta.kubernetes.io/os=linux
kubernetes.io/arch=arm64
kubernetes.io/hostname=k8scluster-m02
kubernetes.io/os=linux
minikube.k8s.io/commit=86fc9d54fca63f295d8737c8eacdbb7987e89c67
minikube.k8s.io/name=k8scluster
minikube.k8s.io/primary=false
minikube.k8s.io/updated_at=2024_09_07T14_23_16_0700
minikube.k8s.io/version=v1.33.0
node-role.kubernetes.io/worker=worker
|
Deployment Pod & Deployment
Pod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# redis-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: redis-pod
spec:
containers:
- name: redis-pod-container
image: redis:7.0.9
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 6379
nodeSelector:
node-role.kubernetes.io/worker: worker
|
1
2
3
4
5
6
|
{seilylook} โก๏ธ kubectl apply -f redis-pod.yaml
pod/redis-pod created
{seilylook} โก๏ธ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
redis-pod 1/1 Running 0 101s 10.244.1.2 k8scluster-m02 <none> <none>
|
Deployment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# httpd-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpd-deploy
spec:
replicas: 5
selector:
matchLabels:
app: httpd
template:
metadata:
labels:
app: httpd
spec:
containers:
- name: httpd-deploy-container
image: httpd:2.4.56
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 80
nodeSelector:
node-role.kubernetes.io/worker: worker
|
1
2
3
4
5
6
7
8
9
10
11
|
{seilylook} โก๏ธ kubectl get deploy -o wide
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
httpd-deploy 5/5 5 5 36s httpd-deploy-container httpd:2.4.56 app=httpd
{seilylook} โก๏ธ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
httpd-deploy-58f57cf68c-7cqkl 1/1 Running 0 45s 10.244.2.4 k8scluster-m03 <none> <none>
httpd-deploy-58f57cf68c-9485h 1/1 Running 0 45s 10.244.2.2 k8scluster-m03 <none> <none>
httpd-deploy-58f57cf68c-bwhh6 1/1 Running 0 45s 10.244.1.4 k8scluster-m02 <none> <none>
httpd-deploy-58f57cf68c-rkhdk 1/1 Running 0 45s 10.244.2.3 k8scluster-m03 <none> <none>
httpd-deploy-58f57cf68c-vkvlz 1/1 Running 0 45s 10.244.1.3 k8scluster-m02 <none> <none>
redis-pod 1/1 Running 0 6m44s 10.244.1.2 k8scluster-m02 <none> <none>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
{seilylook} โก๏ธ kubectl get all -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/httpd-deploy-58f57cf68c-7cqkl 1/1 Running 0 4m25s 10.244.2.4 k8scluster-m03 <none> <none>
pod/httpd-deploy-58f57cf68c-9485h 1/1 Running 0 4m25s 10.244.2.2 k8scluster-m03 <none> <none>
pod/httpd-deploy-58f57cf68c-bwhh6 1/1 Running 0 4m25s 10.244.1.4 k8scluster-m02 <none> <none>
pod/httpd-deploy-58f57cf68c-rkhdk 1/1 Running 0 4m25s 10.244.2.3 k8scluster-m03 <none> <none>
pod/httpd-deploy-58f57cf68c-vkvlz 1/1 Running 0 4m25s 10.244.1.3 k8scluster-m02 <none> <none>
pod/redis-pod 1/1 Running 0 10m 10.244.1.2 k8scluster-m02 <none> <none>
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 42m <none>
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/httpd-deploy 5/5 5 5 4m25s httpd-deploy-container httpd:2.4.56 app=httpd
NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR
replicaset.apps/httpd-deploy-58f57cf68c 5 5 5 4m25s httpd-deploy-container httpd:2.4.56 app=httpd,pod-template-hash=58f57cf68c
|