Skip to content

Commit

Permalink
remove unnecessary navtabs, pass capitalized ca_source_kind to verify…
Browse files Browse the repository at this point in the history
…-upstream-tls-ca template
  • Loading branch information
czeslavo committed Dec 16, 2024
1 parent b8a6e01 commit 98035d0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
25 changes: 13 additions & 12 deletions app/_includes/md/kic/verify-upstream-tls-ca.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
{% assign kind = include.ca_source_type | capitalize %}
{% assign source_type = include.ca_source_kind | downcase %}
{% assign kind = include.ca_source_kind %}
{% assign id = "bf6e0f14-78cd-45ad-9325-87ec7ef7b891" %}
{% if include.ca_source_type == "secret" %}
{% if include.ca_source_kind == "Secret" %}
{% assign id = "bf6e0f14-78cd-45ad-9325-87ec7ef7b892" %}
{% endif %}

First, create a secret with the root CA certificate.
First, create a {{ kind }} with the root CA certificate.

```shell
kubectl create {{ include.ca_source_type }} {% if include.ca_source_type == "secret" %}generic {%endif%}root-ca \
kubectl create {{ source_type }} {% if source_type == "secret" %}generic {%endif%}root-ca \
--from-file=ca.crt=./certs/root.crt \
--from-literal=id={{ id }} # An arbitrary ID for the certificate
kubectl label {{ include.ca_source_type }} root-ca konghq.com/ca-cert=true # This label is required for the CA certificate to be recognized by Kong
kubectl annotate {{ include.ca_source_type }} root-ca kubernetes.io/ingress.class=kong
kubectl label {{ source_type }} root-ca konghq.com/ca-cert=true # This label is required for the CA certificate to be recognized by Kong
kubectl annotate {{ source_type }} root-ca kubernetes.io/ingress.class=kong
```
The results should look like this.
```text
{{ include.ca_source_type }}/root-ca created
{{ include.ca_source_type }}/root-ca labeled
{{ include.ca_source_type }}/root-ca annotated
{{ source_type }}/root-ca created
{{ source_type }}/root-ca labeled
{{ source_type }}/root-ca annotated
```
{% if include.associate_with_service %}
Now, associate the root CA certificate with the `Service` passing its name to `konghq.com/ca-certificates-{{ include.ca_source_type }}` annotation.
Now, associate the root CA certificate with the `Service` passing its name to `konghq.com/ca-certificates-{{ source_type }}` annotation.
{:.note}
> The `konghq.com/ca-certificates-{{ include.ca_source_type }}` annotation is a comma-separated list of `{{ kind }}`s holding CA certificates.
> The `konghq.com/ca-certificates-{{ source_type }}` annotation is a comma-separated list of `{{ kind }}`s holding CA certificates.
> You can add multiple `{{ kind }}`s to the list.
```shell
kubectl annotate service echo konghq.com/ca-certificates-{{ include.ca_source_type }}='root-ca'
kubectl annotate service echo konghq.com/ca-certificates-{{ source_type }}='root-ca'
```
The result should look like this.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,8 @@ verification_.
To configure {{ site.base_gateway }} to verify the certificate of the upstream service,
we need to create a `BackendTLSPolicy` resource:

{% navtabs ca_source %}
<!-- NOTE: Add Secret when https://github.com/Kong/kubernetes-ingress-controller/issues/6834 gets implemented -->
{% navtab ConfigMap %}
<!-- NOTE: Add navtabs with Secret navtab when https://github.com/Kong/kubernetes-ingress-controller/issues/6834 gets implemented -->
{% include /md/kic/verify-upstream-tls-backendtlspolicy.md ref_kind="ConfigMap" %}
{% endnavtab %}
{% endnavtabs %}

The results should look like this.

Expand Down Expand Up @@ -265,12 +261,8 @@ it with the service.
{% navtabs certificate %}
{% navtab Gateway API %}

{% navtabs ca_source %}
<!-- NOTE: Add Secret when https://github.com/Kong/kubernetes-ingress-controller/issues/6834 gets implemented -->
{% navtab ConfigMap %}
{% include /md/kic/verify-upstream-tls-ca.md ca_source_type="configmap" %}
{% endnavtab %}
{% endnavtabs %}
<!-- NOTE: Add navtabs with Secret navtab when https://github.com/Kong/kubernetes-ingress-controller/issues/6834 gets implemented -->
{% include /md/kic/verify-upstream-tls-ca.md ca_source_kind="ConfigMap" %}

The CA is already associated with the `Service` through `BackendTLSPolicy`'s `spec.validation.caCertificateRefs`.

Expand All @@ -279,10 +271,10 @@ The CA is already associated with the `Service` through `BackendTLSPolicy`'s `sp

{% navtabs ca_source %}
{% navtab Secret %}
{% include /md/kic/verify-upstream-tls-ca.md ca_source_type="secret" associate_with_service=true %}
{% include /md/kic/verify-upstream-tls-ca.md ca_source_kind="Secret" associate_with_service=true %}
{% endnavtab %}
{% navtab ConfigMap %}
{% include /md/kic/verify-upstream-tls-ca.md ca_source_type="configmap" associate_with_service=true %}
{% include /md/kic/verify-upstream-tls-ca.md ca_source_kind="ConfigMap" associate_with_service=true %}
{% endnavtab %}
{% endnavtabs %}

Expand Down

0 comments on commit 98035d0

Please sign in to comment.