自己学習用として、軽量な Kubernetes の k3s を OCI の 1GB メモリー環境にインストールして、動作するか試してみました。OCI 環境の OS は、Ubuntu 22.04 を使用しました。
k3s のインストール
$ curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644
Kubernetes ノードを確認
$ kubectl get node
NAME STATUS ROLES AGE VERSION
mnrstinstance02 Ready control-plane,master 23h v1.30.3+k3s1
Kubernetes 内のリソースを全て確認
$ kubectl get all -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system pod/coredns-576bfc4dc7-nllk7 1/1 Running 7 (10h ago) 23h
kube-system pod/helm-install-traefik-cmqwm 0/1 Completed 3 23h
kube-system pod/helm-install-traefik-crd-n6q4r 0/1 Completed 1 23h
kube-system pod/local-path-provisioner-6795b5f9d8-j4z5t 1/1 Running 1 (23h ago) 23h
kube-system pod/metrics-server-557ff575fb-pshvd 1/1 Running 8 (10h ago) 23h
kube-system pod/svclb-traefik-5cd171ac-nv9gz 2/2 Running 0 23h
kube-system pod/traefik-5fb479b77-6xgql 1/1 Running 6 (10h ago) 23h
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default service/kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 23h
kube-system service/kube-dns ClusterIP 10.43.0.10 <none> 53/UDP,53/TCP,9153/TCP 23h
kube-system service/metrics-server ClusterIP 10.43.87.12 <none> 443/TCP 23h
kube-system service/traefik LoadBalancer 10.43.135.141 172.16.0.164 80:30187/TCP,443:32499/TCP 23h
NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
kube-system daemonset.apps/svclb-traefik-5cd171ac 1 1 1 1 1 <none> 23h
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
kube-system deployment.apps/coredns 1/1 1 1 23h
kube-system deployment.apps/local-path-provisioner 1/1 1 1 23h
kube-system deployment.apps/metrics-server 1/1 1 1 23h
kube-system deployment.apps/traefik 1/1 1 1 23h
NAMESPACE NAME DESIRED CURRENT READY AGE
kube-system replicaset.apps/coredns-576bfc4dc7 1 1 1 23h
kube-system replicaset.apps/local-path-provisioner-6795b5f9d8 1 1 1 23h
kube-system replicaset.apps/metrics-server-557ff575fb 1 1 1 23h
kube-system replicaset.apps/traefik-5fb479b77 1 1 1 23h
NAMESPACE NAME STATUS COMPLETIONS DURATION AGE
kube-system job.batch/helm-install-traefik Complete 1/1 4m8s 23h
kube-system job.batch/helm-install-traefik-crd Complete 1/1 2m20s 23h
Nginx を deployment リソースで作成
$ kubectl create deployment nginx --image=nginx
deployment.apps/nginx created
Nginx の deployment リソースの状態を確認
$ kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGE
nginx 1/1 1 1 37s
Nginx の pod リソースの状態を確認
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-bf5d5cf98-98mq6 1/1 Running 0 72s
Nginx にアクセスするための service リソースを作成
$ kubectl expose deployment nginx --type=NodePort --port=80
service/nginx exposed
Nginx の servivce リソースの状態を確認
$ kubectl get service nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx NodePort 10.43.206.82 <none> 80:30455/TCP 36s
Nginx に Curl からアクセス
$ curl localhost:30455
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
service リソースを削除
$ kubectl delete service nginx
service "nginx" deleted
deployment リソースを削除
$ kubectl delete deployment nginx
deployment.apps "nginx" deleted
参考
https://docs.k3s.io/quick-start
タグ: k3s, Kubernetes