LoginSignup
1
1

More than 1 year has passed since last update.

microk8sハマること(Kube内のDNSが参照できない,証明書)

Posted at

デフォでサービス名を参照しない

必須コマンド
microk8s enable dns

microk8sでserviceのDNSが通ってなくて内側からアクセスできない
microk8sベットに設定必要(こんなん気づかんやんfuck)
https://microk8s.io/docs/addon-dns
PodないのDNSみて発覚
root@tasksapp-58b678577f-wkm2j:/# cat /etc/resolv.conf
search {ここに組織のドメイン名}
nameserver 127.0.0.53
options edns0 trust-ad


Kubeconfigがない

taka@doktor:~/kn/knative-docs/docs/serving/samples/hello-world/helloworld-python$ kn service create helloworld-python --image=docker.io/{username}/helloworld-python --env TARGET="Python Sample v1"
Error: no kubeconfig has been provided, please use a valid configuration to connect to the cluster
Run 'kn --help' for usage

移動して解決


vmを再起動するとmicrok8sが使えなくなってしまう

yama@yama-mk8s-1:~$ microk8s kubectl get node
Unable to connect to the server: x509: certificate has expired or is not yet valid: current time 2021-07-14T11:59:19Z is before 2021-07-14T19:32:55Z
yama@yama-mk8s-1:~$ microk8s status
microk8s is not running. Use microk8s inspect for a deeper inspection.

証明書切れの可能性があるが確認したら日数は残っていた

yama@yama-mk8s-1:~$ sudo microk8s.refresh-certs -c
[sudo] password for yama:
The CA certificate will expire in 3612 days.

期限が残っていたが証明書を更新することで解決

yama@yama-mk8s-1:~$ sudo microk8s refresh-certs
Taking a backup of the current certificates under /var/snap/microk8s/2264/var/log/ca-backup/
Creating new certificates
Signature ok
subject=/C=GB/ST=Canonical/L=Canonical/O=Canonical/OU=Canonical/CN=127.0.0.1
Getting CA Private Key
Signature ok
subject=/CN=front-proxy-client
Getting CA Private Key
1
Creating new kubeconfig file
Stopped.
Started.

The CA certificates have been replaced. Kubernetes will restart the pods of your workloads.
Any worker nodes you may have in your cluster need to be removed and re-joined to become aware of the new CA.

yama@yama-mk8s-1:~$ k get node
NAME          STATUS   ROLES    AGE   VERSION
yama-mk8s-3   Ready    <none>   37d   v1.20.7-34+984a1cd176537e
yama-mk8s-2   Ready    <none>   37d   v1.20.7-34+984a1cd176537e
yama-mk8s-1   Ready    <none>   37d   v1.20.7-34+984a1cd176537e
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1