#
cat <<EOF> kind-cni.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
labels:
mynode: control-plane
extraPortMappings:
- containerPort: 30000
hostPort: 30000
- containerPort: 30001
hostPort: 30001
- containerPort: 30002
hostPort: 30002
kubeadmConfigPatches:
- |
kind: ClusterConfiguration
controllerManager:
extraArgs:
bind-address: 0.0.0.0
etcd:
local:
extraArgs:
listen-metrics-urls: http://0.0.0.0:2381
scheduler:
extraArgs:
bind-address: 0.0.0.0
- |
kind: KubeProxyConfiguration
metricsBindAddress: 0.0.0.0
- role: worker
labels:
mynode: worker
- role: worker
labels:
mynode: worker2
networking:
disableDefaultCNI: true
EOF
kind create cluster --config kind-cni.yaml --name myk8s --image kindest/node:v1.30.4
# 배포 확인
kind get nodes --name myk8s
(⎈|kind-myk8s:N/A) root@kind:~# kind get nodes --name myk8s
myk8s-worker2
myk8s-worker
myk8s-control-plane
# 네트워크 확인
kubectl cluster-info dump | grep -m 2 -E "cluster-cidr|service-cluster-ip-range"
(⎈|N/A:N/A) root@kind:~# kubectl cluster-info dump | grep -m 2 -E "cluster-cidr|service-cluster-ip-range"
"--service-cluster-ip-range=10.96.0.0/16",
"--cluster-cidr=10.244.0.0/16",
# flannel 설치 및 namespace 확인
(⎈|kind-myk8s:N/A) root@kind:~# kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
namespace/kube-flannel created
clusterrole.rbac.authorization.k8s.io/flannel created
clusterrolebinding.rbac.authorization.k8s.io/flannel created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.apps/kube-flannel-ds created
(⎈|kind-myk8s:N/A) root@kind:~# kubectl get ns --show-labels
NAME STATUS AGE LABELS
default Active 9m24s kubernetes.io/metadata.name=default
kube-flannel Active 9s k8s-app=flannel,kubernetes.io/metadata.name=kube-flannel,pod-security.kubernetes.io/enforce=privileged
kube-node-lease Active 9m24s kubernetes.io/metadata.name=kube-node-lease
kube-public Active 9m24s kubernetes.io/metadata.name=kube-public
kube-system Active 9m24s kubernetes.io/metadata.name=kube-system
local-path-storage Active 7m16s kubernetes.io/metadata.name=local-path-storage
# kubectl describe pod -n kube-system -l k8s-app=kube-dns
# 브릿지 파일이 없어 오류가 생기고 있는것을 확인 할 수 있습니다!
Warning FailedCreatePodSandBox 25s kubelet Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "8ac0f67e7c8ac0b705f5f98b5678db797daf95b8c14223144df9c397d1c37df9": plugin type="flannel" failed (add): failed to delegate add: failed to find plugin "bridge" in path [/opt/cni/bin]
Normal SandboxChanged 21s (x12 over 32s) kubelet Pod sandbox changed, it will be killed and re-created.
Warning FailedCreatePodSandBox 20s (x4 over 24s) kubelet (combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "25498fd6b78c74571f99295f7e4dd378f89e69f253196c51c02eb81f99876faf": plugin type="flannel" failed (add): failed to delegate add: failed to find plugin "bridge" in path [/opt/cni/bin]
(⎈|kind-myk8s:N/A) root@kind:~# kubectl get pod -A -owide
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
kube-flannel kube-flannel-ds-8tqt6 1/1 Running 0 3m23s 172.18.0.3 myk8s-control-plane <none> <none>
kube-flannel kube-flannel-ds-9ftxz 1/1 Running 0 3m23s 172.18.0.2 myk8s-worker2 <none> <none>
kube-flannel kube-flannel-ds-lzw85 1/1 Running 0 3m23s 172.18.0.4 myk8s-worker <none> <none>
kube-system coredns-7db6d8ff4d-g8n75 1/1 Running 0 10m 10.244.0.3 myk8s-control-plane <none> <none>
kube-system coredns-7db6d8ff4d-jwnn6 1/1 Running 0 10m 10.244.0.2 myk8s-control-plane <none> <none>
kube-system etcd-myk8s-control-plane 1/1 Running 0 12m 172.18.0.3 myk8s-control-plane <none> <none>
kube-system kube-apiserver-myk8s-control-plane 1/1 Running 0 12m 172.18.0.3 myk8s-control-plane <none> <none>
kube-system kube-controller-manager-myk8s-control-plane 1/1 Running 0 12m 172.18.0.3 myk8s-control-plane <none> <none>
kube-system kube-proxy-744r7 1/1 Running 0 10m 172.18.0.3 myk8s-control-plane <none> <none>
kube-system kube-proxy-cmphm 1/1 Running 0 10m 172.18.0.2 myk8s-worker2 <none> <none>
kube-system kube-proxy-nbdg2 1/1 Running 0 10m 172.18.0.4 myk8s-worker <none> <none>
kube-system kube-scheduler-myk8s-control-plane 1/1 Running 0 12m 172.18.0.3 myk8s-control-plane <none> <none>
local-path-storage local-path-provisioner-7d4d9bdcc5-8zsrx 1/1 Running 0 10m 10.244.0.4 myk8s-control-plane <none> <none>