LoginSignup
3
0

More than 1 year has passed since last update.

Azure Kubernetes Service上のcert-managerをバージョンアップする

Posted at

cert-managerは様々な発行元のTLS証明書の管理/更新を自動化するツールです。
AKS上でLets Encryptを自動的に作成、管理する手順は、 公式ページ に記載されています。
1年以上前に導入したcert-managerが古くなってバージョンアップをしたので手順を書き残します。

環境

  • cert-manager
    • 0.8.0
  • AKS
    • 1.21.7

Helmリポジトリアップデート

  • Helmリポジトリを最新化します。
# helm repo list
NAME            URL                       
jetstack        https://charts.jetstack.io
# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "jetstack" chart repository
Update Complete. ⎈Happy Helming!⎈

作業前情報取得

  • 変更前の各種情報を取得しておきます。
# kubectl get all -n cert-manager
# kubectl get crd
# kubectl get clusterissuer
# kubectl describe clusterissuer
# helm list --all-namespaces
# helm history cert-manager -n cert-manager

Helmアップグレード(エラーになる)

  • Helm upgradeをやってみますがエラーになります。k8sバージョンに対してAPIバージョンが古すぎるというエラーのようです。色々試しましたが解決しなかったので一度cert-managerを消して、再インストールすることにしました。cert-managerが一時的に削除されても、通常のアクセスには影響ありません。
# helm upgrade --version vX.X.X cert-manager jetstack/cert-manager -n cert-manager --set installCRDs=true
Error: UPGRADE FAILED: current release manifest contains removed kubernetes api(s) for this kubernetes version and it is therefore unable to build the kubernetes objects for performing the diff. error from kubernetes: unable to recognize "": no matches for kind "Deployment" in version "apps/v1beta1"

cert-manager削除

  • helm uninstallもできない状態だったので、yamlファイルを使ってdeleteします。
# kubectl delete -f https://github.com/jetstack/cert-manager/releases/download/v0.8.0/cert-manager.yaml -n cert-manager
  • 削除後の状態を取得しておきます。namespaceやCRDが消えていることを確認します。
# kubectl get ns
# kubectl get crd

cert-managerインストール

  • cert-managerをインストールします。cert-managerのサポートするk8sバージョンは こちら を参照ください。
# kubectl create namespace cert-manager
# kubectl label namespace cert-manager cert-manager.io/disable-validation=true
# helm install cert-manager --namespace cert-manager --version vX.X.X --set installCRDs=true jetstack/cert-manager

Cluster Issuer設定変更

  • yamlファイルのAPIバージョン等が古くなっていると思われるため修正します。
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt-prod
  namespace: [Your Namespace]
spec:
  acme:
    server: https://acme-v02.api.letsencrypt.org/directory
    email: [Your Email]
    privateKeySecretRef:
      name: letsencrypt-prod
    solvers:
    - http01:
        ingress:
          class: nginx
  • Cluster Issuerを再作成します。
# kubectl get clusterissuer
# kubectl apply -f cluster-issuer.yaml
# kubectl get clusterissuer

Ingress設定変更

  • Ingressに設定しているannnotationsが古いため修正します。
# vi ingress.yaml
certmanager.k8s.io/cluster-issuer: letsencrypt-prod
↓
cert-manager.io/cluster-issuer: letsencrypt-prod
  • Ingressを設定変更します。
# kubectl get Ingress
# kubectl describe ingress
# kubectl apply -f ingress.yaml
# kubectl get Ingress
# kubectl describe ingress
  • しばらくして証明書が更新されていればOKです。

以上

3
0
1

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
3
0