[k8s] Antikythera on Kubernetes
Antikythera on Kubernetes - 1 セットアップ
N100ミニPC(8GB/512GB)を18kで買ったのでProxmox を入れて1台のみのPCで Kubernetes クラスタを作ります。 さらに Antikythera をそのクラスタ上で動かしてみたいと思います。 Antikythera はOSSなので誰でも試すことができます。
ミニPCのセットアップ
Proxmox のインストール
Prepare Installation Media - Proxmox VE みてインストールした
dd bs=1M conv=fdatasync if=./proxmox-ve_*.iso of=/dev/sda- IPv4/CIDR: 192.168.11.10/24
- Gateway: 192.168.11.11
- FQDN:
pve.local - Web UI: https://192.168.11.10:8006
ルーターの設定を確認
- subnet: 192.168.11.0/24 (CIDR表記)
network周りどうなっているの?
enp3s0が物理ネットワークインターフェイスvmbr0がLinux bridge
https://yoshi0808.github.io/new-technology/2024/02/19/Proxmox-new-vm/
Kubernetes clusterセットアップ
VMを作成して、クラスターを作成する
おうちKubernetesを構築した話 に記載されているセットアップ方法に従いKubernetes クラスターの作成まで行います。
Kubernetesダッシュボード有効化
- Web UI (Dashboard) | Kubernetes
- dashboard/docs/user/access-control/creating-sample-user.md at master · kubernetes/dashboard · GitHub
# (host)
# 1. deploy dashboard
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
# 2. create service account
$ code dashboard-adminuser.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
$ kubectl apply -f dashboard-adminuser.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kubernetes-dashboard
$ kubectl apply -f dashboard-adminuser.yaml
# copy token
$ kubectl -n kubernetes-dashboard create token admin-user | xsel -bi
# 3. open dashboard
$ kubectl proxy
Starting to serve on 127.0.0.1:8001
$ open http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login
# list notes
# http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/node?namespace=default
# 4. delete service account
$ kubectl -n kubernetes-dashboard delete serviceaccount admin-user
$ kubectl -n kubernetes-dashboard delete clusterrolebinding admin-user
# 5. delete dashboard
$ kubectl delete -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
コンテナをデプロイするには
参考: kubernetes(k8s)を使ってローカル開発を行う
DockerHubにrepository作成後
docker build --no-cache -t wakametech/python-fastapi:v1 .
docker login
docker push wakametech/python-fastapi:v1
kubectl apply -f ./k8s/python-fastapi.yaml
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm install ingress-nginx ingress-nginx/ingress-nginx
kubectl get services
helm uninstall ingress-nginx
LoadBalancerが <pending> のまま
Custom clusterでは TYPE=LoadBalancer 使えないらしい. Ingress Controllerを使えとのこと
nginx - Kubernetes service external ip pending - Stack Overflow
kubectl apply -f https://raw.githubusercontent.com/traefik/traefik/v1.7/examples/k8s/traefik-deployment.yaml
kubectl apply -f https://raw.githubusercontent.com/traefik/traefik/v1.7/examples/k8s/traefik-ds.yaml
code k8s/example-ingress.yaml
kubectl apply -f k8s/example-ingress.yaml
kubectl get ingress -w # ADDRESSを確認