LoginSignup
3
0

More than 1 year has passed since last update.

TCE+cert-managerで自己証明書をつくってみる

Last updated at Posted at 2021-12-09

はじめに

本投稿では「TUNA-JP Advent Calendar 2021」の9日目のエントリとして、
TCE+cert-manager で自己証明書を作ってみたという内容について記載します。

正確には TCE(Tanzu Community Edition) の公式ページの Packages->cert-manager ページのデモを
実際に TCE を立てて触ってみようという内容です。

本記事では、手始めに cert-manager のクラスター内での root certificate authority(CA) を作成する
デモを実践してみたいと思います。

cert-manager ってなに?という方に最適です。肩肘を張らずにお付き合いください。

cert-managerってなに?

cert-manager は kubernetes 内で様々なソースから証明書を追加したり、証明書の発行機関を追加できたりするもので、
環境内の証明書の取得や更新を簡単におこなえるメリットがあるものです。

実際にさわってみよう

cert-manager の動作確認には kubernetes 環境が必要になります。
今回は TCE の環境を構築して、cert-manager をインストールして行きたいと思います。

TCE 環境で cert-manager を試すには、AWS、Azure、vSphere のいずれかの環境を用意する必要があります。

今回 Docker にインストールしたクラスターの環境でも展開できたら、試すのが楽なのになと思いましたが、
できないのは仕方がないので、vSphere 環境に TCE をデプロイして早速 cert-manager をインストールします。

デプロイ方法としては以下の2つを試しました。
・management cluster -> workload cluster
・standalone cluster

今回は上手くデプロイできた standalone cluster でデモを
試していきたいと思います。

ドキュメントとしては以下を参照しました。
* Documentation
https://tanzucommunityedition.io/docs/latest/vsphere-install-standalone/

$ tanzu standalone-cluster create -i docker test-cluster
Downloading TKG compatibility file from 'projects.registry.vmware.com/tkg/framework-zshippable/tkg-compatibility'
Downloading the TKG Bill of Materials (BOM) file from 'projects.registry.vmware.com/tkg/tkg-bom:v1.4.0'
Downloading the TKr Bill of Materials (BOM) file from 'projects.registry.vmware.com/tkg/tkr-bom:v1.21.2_vmware.1-tkg.1'

Validating the pre-requisites...
Identity Provider not configured. Some authentication features won't work.

Setting up standalone cluster...
Validating configuration...
Using infrastructure provider docker:v0.3.23
Generating cluster configuration...
Setting up bootstrapper...
Bootstrapper created. Kubeconfig: /home/takayuki/.kube-tkg/tmp/config_JmihfUpj
Installing providers on bootstrapper...
Start creating standalone cluster...
Saving standalone cluster kubeconfig into /home/takayuki/.kube/config
Waiting for bootstrap cluster to get ready for save ...
Waiting for addons installation...
Moving all Cluster API objects from bootstrap cluster to standalone cluster...
Context set for standalone cluster test-cluster as 'test-cluster-admin@test-cluster'.
Cleaning up unneeded resources (for standalone clusters)...

Standalone cluster created!

上記でインストール完了!
スタンドアローンクラスターのインストールドキュメントだけ画像付きで
丁寧なドキュメントになっていて親切です。

早速 cert-manager をインストールして、デモを試していきます。
参照するドキュメントは以下です。
* Documentation
https://tanzucommunityedition.io/docs/latest/package-readme-cert-manager-1.4.4/

まずパッケージをインストールするためにレポジトリを追加します。
以下のコマンドですべてのネームスペースに対してインストールできます。
* Documentation
https://tanzucommunityedition.io/docs/latest/package-management/

tanzu package repository add tce-repo \
  --url projects.registry.vmware.com/tce/main:0.9.1 \
  --namespace tanzu-package-repo-global

次にインストールできる cert-manager のバージョンを確認してインストール。

$ tanzu package available list cert-manager.community.tanzu.vmware.com -A --namespace demo-cert-mgmt
/ Retrieving package versions for cert-manager.community.tanzu.vmware.com...
  NAME                                     VERSION  RELEASED-AT           NAMESPACE
  cert-manager.community.tanzu.vmware.com  1.3.3    2021-08-06T12:31:21Z  tanzu-package-repo-global
  cert-manager.community.tanzu.vmware.com  1.4.4    2021-08-23T16:47:51Z  tanzu-package-repo-global
  cert-manager.community.tanzu.vmware.com  1.5.3    2021-08-23T17:22:51Z  tanzu-package-repo-global

$ tanzu package install cert-manager --package-name cert-manager.community.tanzu.vmware.com --version 1.4.4 --namespace demo-cert-mgmt
/ Installing package 'cert-manager.community.tanzu.vmware.com'
| Getting namespace 'demo-cert-mgmt'
| Getting package metadata for 'cert-manager.community.tanzu.vmware.com'
| Creating service account 'cert-manager-demo-cert-mgmt-sa'
| Creating cluster admin role 'cert-manager-demo-cert-mgmt-cluster-role'
| Creating cluster role binding 'cert-manager-demo-cert-mgmt-cluster-rolebinding'
- Creating package resource
\ Package install status: Reconciling

 Added installed package 'cert-manager' in namespace 'demo-cert-mgmt'

早速デモを試しましょうと思ったら、以下のエラーに遭遇しました。
どうやらインストールしたスタンドアローンクラスターのIPに接続できない様子です。

$ cat <<EOF | kubectl apply --namespace demo-cert-mgmt --filename -
> apiVersion: cert-manager.io/v1
> kind: Issuer
> metadata:
>   name: self-signed
> spec:
>   selfSigned: {}
> EOF
Unable to connect to the server: dial tcp 151.xxx.xxx.xxx:6443: connect: no route to host

これは環境要因ですね。。。解決するにはネットワーク構成触らないといけない状況になってしまいました。
年内の解決は難しそうなので、来年の宿題になってしまいそうです。

アドベントと言いつつ、1月更新になってしまいそうですが、
最後までやりきる所存です。
...

寿司ネタで言うシャリのみでネタがないみたいな記事になってしまいました。
後ほど更新しますので気長にお待ちいただけると嬉しいです。

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