출처 : 도커
가상머신에 Minikube 설치하기 (with Docker)
sudo usermod -aG docker server && newgrp docker |
wget https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb |
sudo dpkg -i minikube_latest_amd64.deb |
minikube start --driver=docker |
curl -LO https://dl.k8s.io/release/v1.22.1/bin/linux/amd64/kubectl |
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl |
kubectl --help |
미니 쿠베 설치완료
cd 계정 홈디렉토리로 이동 환경변수 편집 vi .bashrc 알리랑스 입력 alias k='kubectl' 환경변수 재실행 source .bashrc |
server@ubuntu24:~$ k get pod -n kube-system NAME READY STATUS RESTARTS AGE coredns-6f6b679f8f-5hh6q 1/1 Running 0 6m25s etcd-minikube 1/1 Running 0 6m33s kube-apiserver-minikube 1/1 Running 0 6m33s kube-controller-manager-minikube 1/1 Running 0 6m30s kube-proxy-sb56h 1/1 Running 0 6m26s kube-scheduler-minikube 1/1 Running 0 6m33s storage-provisioner 1/1 Running 2 (6m21s ago) 6m28s server@ubuntu24:~$ server@ubuntu24:~$ k get nodes NAME STATUS ROLES AGE VERSION minikube Ready control-plane 10m v1.31.0 server@ubuntu24:~$ k get all NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 11m server@ubuntu24:~$ k get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 11m server@ubuntu24:~$ server@ubuntu24:~$ k create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.10 deployment.apps/hello-minikube created server@ubuntu24:~$ k expose deployment hello-minikube --type=NodePort --port=8080 service/hello-minikube exposed server@ubuntu24:~$ k expose deployment hello-minikube --type=NodePort --port=8080 Error from server (AlreadyExists): services "hello-minikube" already exists server@ubuntu24:~$ k expose deployment hello-minikube --type=nginx --port=80 The Service "hello-minikube" is invalid: spec.type: Unsupported value: "nginx": supported values: "ClusterIP", "ExternalName", "LoadBalancer", "NodePort" server@ubuntu24:~$ k get all NAME READY STATUS RESTARTS AGE pod/hello-minikube-66fcf97965-n28d6 1/1 Running 0 2m11s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/hello-minikube NodePort 10.106.104.194 <none> 8080:30891/TCP 103s service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 18m NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/hello-minikube 1/1 1 1 2m12s NAME DESIRED CURRENT READY AGE replicaset.apps/hello-minikube-66fcf97965 1 1 1 2m11s server@ubuntu24:~$ server@ubuntu24:~$ k get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-minikube NodePort 10.106.104.194 <none> 8080:30891/TCP 112s kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 18m server@ubuntu24:~$ server@ubuntu24:~$ k get all NAME READY STATUS RESTARTS AGE pod/hello-minikube-66fcf97965-n28d6 1/1 Running 0 4m4s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/hello-minikube NodePort 10.106.104.194 <none> 8080:30891/TCP 3m36s service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 20m NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/hello-minikube 1/1 1 1 4m5s NAME DESIRED CURRENT READY AGE replicaset.apps/hello-minikube-66fcf97965 1 1 1 4m4s server@ubuntu24:~$ kubectl port-forward service/hello-minikube 8080:8080 Forwarding from 127.0.0.1:8080 -> 8080 Forwarding from [::1]:8080 -> 8080 활성화 외부 내부 연계 server@ubuntu24:~$ minikube addons enable ingress * ingress is an addon maintained by Kubernetes. For any concerns contact minikube on GitHub. You can view the list of minikube maintainers at: https://github.com/kubernetes/minikube/blob/master/OWNERS - Using image registry.k8s.io/ingress-nginx/controller:v1.11.2 - Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.4.3 - Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.4.3 * Verifying ingress addon... server@ubuntu24:~$ k get service hello-minikube NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-minikube NodePort 10.106.104.194 <none> 8080:30891/TCP 13m server@ubuntu24:~$ server@ubuntu24:~$ server@ubuntu24:~$ minikube service hello-minikube |-----------|----------------|-------------|---------------------------| | NAMESPACE | NAME | TARGET PORT | URL | |-----------|----------------|-------------|---------------------------| | default | hello-minikube | 8080 | http://192.168.49.2:30891 | |-----------|----------------|-------------|---------------------------| * Opening service default/hello-minikube in default browser... http://192.168.49.2:30891 |