14.5. カスタムドメイン Ingress Controller の作成
証明書リソースを作成して設定し、カスタムドメイン Ingress Controller の証明書をプロビジョニングします。
注記次の例では、単一のドメイン証明書を使用します。SAN およびワイルドカード証明書もサポートされています。
$ cat << EOF | oc apply -f - apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: custom-domain-ingress-cert namespace: openshift-ingress spec: secretName: custom-domain-ingress-cert-tls issuerRef: name: letsencrypt-production kind: ClusterIssuer commonName: "${DOMAIN}" dnsNames: - "${DOMAIN}" EOF
証明書が発行されたことを確認します。
注記Let's Encrypt によってこの証明書が発行されるまでに数分かかります。5 分以上かかる場合は、
oc -n openshift-Ingress describe certificate.cert-manager.io/custom-domain-Ingress-cert
を実行して、cert-manager によって報告された問題を確認します。$ oc -n openshift-ingress get certificate.cert-manager.io/custom-domain-ingress-cert
出力例
NAME READY SECRET AGE custom-domain-ingress-cert True custom-domain-ingress-cert-tls 9m53s
新規の
IngressController
リソースを作成します。$ cat << EOF | oc apply -f - apiVersion: operator.openshift.io/v1 kind: IngressController metadata: name: custom-domain-ingress namespace: openshift-ingress-operator spec: domain: ${DOMAIN} defaultCertificate: name: custom-domain-ingress-cert-tls endpointPublishingStrategy: loadBalancer: dnsManagementPolicy: Unmanaged providerParameters: aws: type: NLB type: AWS scope: External type: LoadBalancerService EOF
警告この
IngressController
の例では、インターネットにアクセス可能な Network Load Balancer (NLB) を AWS アカウントに作成します。代わりに内部 NLB をプロビジョニングするには、IngressController
リソースを作成する前に、.spec.endpointPublishingStrategy.loadBalancer.scope
パラメーターをInternal
に設定します。カスタムドメイン IngressController が外部ロードバランサーを正常に作成したことを確認します。
$ oc -n openshift-ingress get service/router-custom-domain-ingress
出力例
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE router-custom-domain-ingress LoadBalancer 172.30.174.34 a309962c3bd6e42c08cadb9202eca683-1f5bbb64a1f1ec65.elb.us-east-1.amazonaws.com 80:31342/TCP,443:31821/TCP 7m28s
カスタムドメイン Ingress Controller の DNS 解決を有効にするために必要な DNS 変更を含むドキュメントを準備します。
$ INGRESS=$(oc -n openshift-ingress get service/router-custom-domain-ingress -ojsonpath="{.status.loadBalancer.ingress[0].hostname}") $ cat << EOF > "${SCRATCH}/create-cname.json" { "Comment":"Add CNAME to custom domain endpoint", "Changes":[{ "Action":"CREATE", "ResourceRecordSet":{ "Name": "*.${DOMAIN}", "Type":"CNAME", "TTL":30, "ResourceRecords":[{ "Value": "${INGRESS}" }] } }] } EOF
変更を伝播するために Amazon Route 53 に送信します。
$ aws route53 change-resource-record-sets \ --hosted-zone-id ${ZONE_ID} \ --change-batch file://${SCRATCH}/create-cname.json
注記ワイルドカード CNAME レコードを使用すると、カスタムドメイン Ingress Controller を使用してデプロイする新しいアプリケーションごとに新しいレコードを作成する必要がなくなりますが、これらの各アプリケーションが使用する証明書は、ワイルドカード証明書 ではありません。