【IBM Application Gateway】ROKS上でsealedsecret を使ってSecretを暗号化してみる

# はじめに
これまでの記事では、Secretは[IBM Application Gateway Deployment Asset](https://github.com/jonpharry/iag) に含まれているシェルスクリプトを使って、事前登録しておく前提でした。
- [【IBM Application Gateway】IBM CloudにGitLabのリポジトリーを作成&利用してみる](https://qiita.com/fitz/items/551bac934071056967e1)
- [【IBM Application Gateway】OpenShift GitOps(Argo CD)を使ってアプリをデプロイする](https://qiita.com/fitz/items/5449f07b2f708b549b84)

今回は、以下の記事を参考に、ROKS上でsealedsecret を使ってSecretを暗号化してみました。
[SealedSecretを用いてSecretを暗号化する](https://qiita.com/butterv/items/877b0a499becbabf3398)


# 1.Kubesealのインストール
Windows/powershell環境で実施しているため、リンク先からモジュール（kubeseal-0.18.0-windows-amd64.tar.gz）をダウンロードしました。
https://github.com/bitnami-labs/sealed-secrets/releases

![qiita (1).png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/678692/4040d1f1-23aa-ce56-60e8-48fc3c28ec92.png)


任意のディレクトリに解凍/Path設定を行い、「kubeseal --help」が実行できることを確認します。
![qiita (2).png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/678692/2962396d-763e-249c-9db3-586aebd5b50b.png)


# 2.sealed-secretsコントローラー設定

最新のv0.18.0を使って設定します。
```
oc apply -f https://github.com/bitnami-labs/sealed-secrets/releases/download/v0.18.0/controller.yaml
```

sealed-secrets-controllerのPODがRunnningになっていることを確認します。
```
PS C:\temp-openshift\iag> oc get pods -n kube-system
NAME                                             READY   STATUS    RESTARTS   AGE
～～～
sealed-secrets-controller-b8b7484d5-zr9kv        1/1     Running   0          60s
～～～

```



# 3.公開鍵の取得

Secretを暗号化するための公開鍵を取得します。
リダイレクトでファイル出力すると、暗号化したSecretを作成する際に、error: data does not contain any valid RSA or ECDSA certificatesというエラーが表示されたためです。

参考：[「SealedSecrets」を使ってKubernetesのSecretをGitで管理する](https://ascii.jp/elem/000/004/093/4093831/)

```
kubeseal --fetch-cert -w .\base\files\cert.pem
```

# 4.Secretの準備/暗号化

暗号化するSecretを用意します。

- S_OIDC_CLIENT_SECRET
    - Security Verifyで発行したClient_Secret
- iag.certkey.pem
    - IBM Application Gatewayが利用するSSL証明書
あとは、バックエンドアプリにあわせて証明書など追加します。

```secret.yaml
apiVersion: v1
kind: Secret
data:
  S_OIDC_CLIENT_SECRET: em~~~==
  iag.certkey.pem: L~~0K
  au-syd-mybluemix-net-chain.pem: LS~~0K
  au-syd-mybluemix-net.pem: LS~~==
metadata:
  name: iag
type: Opaque
```

Secretを暗号化します。パスは適宜変更ください。

```
kubeseal --format=yaml --cert=.\base\files\cert.pem -f .\base\files\secret.yaml -w .\base\sealed-secret.yaml
```


なお、Powershellでは"<"は予約語となっていて、利用できませんでした。
このため、-fオプションを使ってインプットファイルを指定しました。

```
> kubeseal --format=yaml --cert=.\base\files\cert.pem < .\base\files\secret.yaml > .\base\sealed-secret.yaml
発生場所 行:1 文字:53
演算子 '<' は、今後の使用のために予約されています。
発生場所 行:1 文字:53
+ kubeseal --format=yaml --cert=.\base\files\cert.pem < .\base\files\se ...
+                                                     ~
演算子 '<' は、今後の使用のために予約されています。
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RedirectionNotSupported

```


生成されたファイルを確認します。
kindがSecret→SealedSecretになっています。


```sealed-secret.yaml
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
  creationTimestamp: null
  name: iag
  namespace: iag-kustomize
spec:
  encryptedData:
    S_OIDC_CLIENT_SECRET: AgBu2fnG06+TInW1D7cv/WCYRyM8DZBr5cEZhCcUVw7FfKs/dOokgAWVbzUZ1tfDQtygxzhzWPrLQpi3+tzV2OAVbFIP+dp5wcfuJI+EKMzz3LDT89dXNpEUuOBDswqyjRZ7ir4HFlJztIIbUmUCEfqNBHB++Wvmu1iemh4X0IKcPswl3eb0HK947odChz1m4TLOtZy0T7kYtkAxgwm03UcpN4XSlnuewVQ53nlpG7I4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cnjZT2czTGF2I8WrFMNgaX1jAcM/s6naZgbC3VOhPklsW5VmTOVXj0yKMUrR7uExj74gTCyd0Gk2jzz1Xb+3WoUciRLO/ceTw/ACGsNgMR+HtmK7hlz+MpJKP+okJkCkekUcx7sxsOrTANQq9yQKXPqKPuynMCQAaeZqQ80yl8uZTF8g=
  template:
    data: null
    metadata:
      creationTimestamp: null
      name: iag
      namespace: iag-kustomize
    type: Opaque
```



# 5.SealedSecret.yamlの登録

暗号化されたSealedSecret.yamlを登録します。

```
> oc apply -f .\base\sealed-secret.yaml
sealedsecret.bitnami.com/iag created
```

復号化された状態でSecretが登録されます。

```
> oc get secret iag
NAME   TYPE     DATA   AGE
iag    Opaque   5      15s

>oc edit secret iag

apiVersion: v1
data:
  S_OIDC_CLIENT_SECRET: em~~==
  au-syd-mybluemix-net-chain.pem: LS~~0K
  au-syd-mybluemix-net.pem: LS~~==
  iag.certkey.pem: LS~~0K
kind: Secret
metadata:
  creationTimestamp: "2022-06-10T09:31:08Z"
  name: iag
  namespace: iag-gitops
  ownerReferences:
  - apiVersion: bitnami.com/v1alpha1
    controller: true
    kind: SealedSecret
    name: iag
    uid: 5b5b798c-7b8f-47a2-a1bf-fc232c8d9a8e
  resourceVersion: "172916210"
  selfLink: /api/v1/namespaces/iag-gitops/secrets/iag
  uid: 1f49931a-9908-4477-a625-4341e8ae60b1
type: Opaque
```

SealedSecretとしても登録されます。
```
> oc get sealedsecret
NAME   AGE
iag    7s
```

なお、Secretを削除したところ、以下の動きとなりました。
- SealedSecretを削除すると、Secretも削除される。
- Secretを削除しても、SealedSecretは残ったまま


# 最後に
Secretを暗号化できたことで、Github上にSecretを暗号化した状態で保管できるようになりました。