쿠버네티스를 구축하는 방법은 여러가지가 있다. 내 컴퓨터에 직접 설치하거나, 가상머신을 만들어서 설치하는 - minikube, MicroK8s 등의 방법이 있다.
The Kubeadmin tool is used to bootstrap and manage production grade Kubernetes cluster.

미니큐브
Minikube bundles, all of these different components into a single image, providing us a preconfigured single node, kubernetes cluster, so we can get started in a matter of minutes. The whole bundle is packaged into an ISO iamge and is available online for download

미니큐브 설치
미니큐브 설치는 필자의 다른 포스팅에서 Vagrant를 이용하여 Linux VM을 생성하는 방법을 설명하였다. 그 학습환경에 이어서 Vagrant로 생성된 리눅스 VM에서 미니큐브를 설치하겠다.
C 드라이브의 HashiCorp 디렉토리로 이동하여 VM을 시작한다.
C:\HashiCorp\ubuntu>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/focal64' version '20220901.0.0' is up to date...
==> default: A newer version of the box 'ubuntu/focal64' for provider 'virtualbox' is
==> default: available! You currently have version '20220901.0.0'. The latest is version
==> default: '20220902.0.0'. Run `vagrant box update` to update.
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
C:\HashiCorp\ubuntu>
이어서 시작된 VM으로 SSH 접속

minikube start
minikube is local Kubernetes
minikube.sigs.k8s.io
▶ 미니큐브 설치를 위한 준비 작업
- 도커가 먼저 설치되어 있어야 한다.
- 2 CPUs or more
- 2GB of free memory
- 20GB of free disk space
가장 최근 버전의 미니큐브를 리눅스 환경에서 설치하려면 다음 명령어를 입력한다.
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
실행
vagrant@ubuntu-focal:~$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 72.0M 100 72.0M 0 0 67.1M 0 0:00:01 0:00:01 --:--:-- 67.1M
vagrant@ubuntu-focal:~$ sudo install minikube-linux-amd64 /usr/local/bin/minikube
vagrant@ubuntu-focal:~$
미니큐브 설치
vagrant@ubuntu-focal:~$ minikube start
😄 minikube v1.26.1 on Ubuntu 20.04 (vbox/amd64)
✨ Automatically selected the docker driver. Other choices: ssh, none
📌 Using Docker driver with root privileges
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
💾 Downloading Kubernetes v1.24.3 preload ...
> preloaded-images-k8s-v18-v1...: 405.75 MiB / 405.75 MiB 100.00% 72.58 M
> gcr.io/k8s-minikube/kicbase: 386.60 MiB / 386.61 MiB 100.00% 14.50 MiB
> gcr.io/k8s-minikube/kicbase: 0 B [________________________] ?% ? p/s 18s
🔥 Creating docker container (CPUs=2, Memory=2200MB) ...
🐳 Preparing Kubernetes v1.24.3 on Docker 20.10.17 ...
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: storage-provisioner, default-storageclass
💡 kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
vagrant@ubuntu-focal:~$
kubectl 설치
vagrant@ubuntu-focal:~$ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 138 100 138 0 0 797 0 --:--:-- --:--:-- --:--:-- 797
100 42.9M 100 42.9M 0 0 32.2M 0 0:00:01 0:00:01 --:--:-- 95.0M
vagrant@ubuntu-focal:~$ sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
vagrant@ubuntu-focal:~$
확인
vagrant@ubuntu-focal:~$ kubectl version --output=yaml
clientVersion:
buildDate: "2022-08-23T17:44:59Z"
compiler: gc
gitCommit: a866cbe2e5bbaa01cfd5e969aa3e033f3282a8a2
gitTreeState: clean
gitVersion: v1.25.0
goVersion: go1.19
major: "1"
minor: "25"
platform: linux/amd64
kustomizeVersion: v4.5.7
serverVersion:
buildDate: "2022-07-13T14:23:26Z"
compiler: gc
gitCommit: aef86a93758dc3cb2c658dd9657ab4ad4afc21cb
gitTreeState: clean
gitVersion: v1.24.3
goVersion: go1.18.3
major: "1"
minor: "24"
platform: linux/amd64
vagrant@ubuntu-focal:~$
vagrant@ubuntu-focal:~$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
vagrant@ubuntu-focal:~$
vagrant@ubuntu-focal:~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane 23m v1.24.3
vagrant@ubuntu-focal:~$
▶ Deploy Application
vagrant@ubuntu-focal:~$ kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4
deployment.apps/hello-minikube created
vagrant@ubuntu-focal:~$ kubectl expose deployment hello-minikube --type=NodePort --port=8080
service/hello-minikube exposed
vagrant@ubuntu-focal:~$
It may take a moment, but your deployment will soon show up when you run:
vagrant@ubuntu-focal:~$ kubectl get services hello-minikube
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-minikube NodePort 10.97.41.105 <none> 8080:30232/TCP 28s
vagrant@ubuntu-focal:~$
The easiest way to access this service is to let minikube launch a web browser for you:
vagrant@ubuntu-focal:~$ minikube service hello-minikube
|-----------|----------------|-------------|---------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|----------------|-------------|---------------------------|
| default | hello-minikube | 8080 | http://192.168.49.2:30232 |
|-----------|----------------|-------------|---------------------------|
🎉 Opening service default/hello-minikube in default browser...
👉 http://192.168.49.2:30232
vagrant@ubuntu-focal:~$ curl 192.168.49.2:30232
CLIENT VALUES:
client_address=172.17.0.1
command=GET
real path=/
query=nil
request_version=1.1
request_uri=http://192.168.49.2:8080/
SERVER VALUES:
server_version=nginx: 1.10.0 - lua: 10001
HEADERS RECEIVED:
accept=*/*
host=192.168.49.2:30232
user-agent=curl/7.68.0
BODY:
-no body in request-
vagrant@ubuntu-focal:~$
정리
vagrant@ubuntu-focal:~$ kubectl delete services hello-minikube
service "hello-minikube" deleted
vagrant@ubuntu-focal:~$ kubectl delete deployment hello-minikube
deployment.apps "hello-minikube" deleted
vagrant@ubuntu-focal:~$ kubectl get pod
No resources found in default namespace.
vagrant@ubuntu-focal:~$'DevOps > DockerKubernetes' 카테고리의 다른 글
| Pod (0) | 2022.09.04 |
|---|---|
| 우분투 리눅스에서 도커 설치 (0) | 2022.09.04 |
| 쿠버네티스 아키텍처 (0) | 2022.09.04 |
| (Windows) Vagrant로 Linux(ubuntu) VM 단번에 생성하기 (0) | 2022.09.03 |
| kubernetes를 사용하면 무엇을 할 수 있을까? (0) | 2022.09.03 |