1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OpenShiftでAPI証明書の期限が切れた場合の復旧方法

Posted at

はじめに

本記事では、OCPのAPI証明書の期限が切れて、APIアクセスできなくなった場合に、API証明書を更新して復旧する手順を示します。
OCPのAPI証明書は1ヶ月ごとに自動更新されますが、OCPノードが1ヶ月以上の長期に渡って停止状態にするなどして自動更新できなかったケースにおいて、起動後に手動更新してAPIアクセスを復旧する必要があります。

目次

  1. API証明書の更新手順
  2. まとめ
  3. 参考文献

API証明書の更新手順

API証明書の期限が切れた状態で、oc loginしようとすると、下記のようなエラーが返ります。

# oc login https://<IP_address>:6443 -u <user> -p <password>
Unable to connect to the server: EOF

復旧作業はmasterノードから行う必要があるため、いずれかのmasterノードへSSHログインします。

# ssh core@<master_node>

rootユーザになります。

# sudo -i

環境変数KUBECONFIGにkubeconfigファイルを指定して、ocコマンドを実行できる状態にします。(指定するkubeconfigファイルは参考文献参照)

# export KUBECONFIG=/etc/kubernetes/static-pod-resources/kube-apiserver-certs/secrets/node-kubeconfigs/lb-int.kubeconfig

Pending状態になっているCSRを承認します。(PendingのCSRがなくなるまで繰り返し実行します)

# oc get csr | grep Pending | awk '{print $1}' | xargs -I{} oc adm certificate approve {}

最後に、openshift-apiserver namespaceのpodをdeleteして再起動します。

# oc -n openshift-apiserver delete pods --all

podが起動するまで待ちます。

# oc -n openshift-apiserver get pods

pod起動後に、oc loginができるようになります。

# oc login https://<IP_address>:6443 -u <user> -p <password>

まとめ

1ヶ月以上OCPノードを停止するなどAPI証明書を自動更新できない場合は、次回起動の際にAPI証明書が切れた状態となり、oc loginもできない状態となるため、上記のような手動での復旧作業が必要となります。

参考文献

1
1
2

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?