Skip to content

Commit 556ecd2

Browse files
authored
docs: update cluster-proxy blog post to use kind cluster's root CA for TLS certificates (#531)
Replace self-signed CA with kind cluster's root CA to allow all pods and services in the kind cluster to automatically trust cluster-proxy certificates without additional CA certificate mounting. Signed-off-by: xuezhaojun <[email protected]>
1 parent 4893301 commit 556ecd2

File tree

1 file changed

+16
-39
lines changed
  • content/en/blog/cluster-proxy-support-service-proxy

1 file changed

+16
-39
lines changed

content/en/blog/cluster-proxy-support-service-proxy/index.md

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -84,57 +84,34 @@ kubectl --context kind-hub apply -f https://github.com/cert-manager/cert-manager
8484
kubectl --context kind-hub wait --for=condition=ready pod -l app.kubernetes.io/instance=cert-manager -n cert-manager --timeout=300s
8585
```
8686

87-
Next, create the certificate resources:
87+
Next, create the certificate resources using the kind cluster's root CA. This approach allows all pods and services in the kind cluster to automatically trust the cluster-proxy certificates without requiring additional CA certificate mounting:
8888

8989
```shell
90+
# Create namespace and certificates using kind cluster's CA
91+
kubectl --context kind-hub create namespace open-cluster-management-addon
92+
CA_CRT=$(kubectl --context kind-hub config view --raw -o jsonpath='{.clusters[?(@.name=="kind-hub")].cluster.certificate-authority-data}')
93+
CA_KEY=$(docker exec hub-control-plane cat /etc/kubernetes/pki/ca.key | base64 -w 0)
94+
9095
kubectl --context kind-hub apply -f - <<EOF
9196
apiVersion: v1
92-
kind: Namespace
93-
metadata:
94-
name: open-cluster-management-addon
95-
---
96-
# Self-signed Issuer for bootstrapping the CA certificate
97-
apiVersion: cert-manager.io/v1
98-
kind: Issuer
97+
kind: Secret
9998
metadata:
100-
name: selfsigned-issuer
99+
name: kind-cluster-ca
101100
namespace: open-cluster-management-addon
102-
spec:
103-
selfSigned: {}
104-
---
105-
# CA Certificate for cluster-proxy
106-
# This creates a self-signed CA that will be used to issue certificates for services
107-
apiVersion: cert-manager.io/v1
108-
kind: Certificate
109-
metadata:
110-
name: cluster-proxy-ca
111-
namespace: open-cluster-management-addon
112-
spec:
113-
isCA: true
114-
commonName: cluster-proxy-ca
115-
secretName: cluster-proxy-ca-secret
116-
duration: 87600h # 10 years
117-
privateKey:
118-
algorithm: RSA
119-
size: 4096
120-
issuerRef:
121-
name: selfsigned-issuer
122-
kind: Issuer
123-
101+
type: kubernetes.io/tls
102+
data:
103+
tls.crt: ${CA_CRT}
104+
tls.key: ${CA_KEY}
124105
---
125-
# Issuer that uses the CA certificate to issue certificates
126-
# Changed from ClusterIssuer to Issuer to allow accessing secret in the same namespace
127106
apiVersion: cert-manager.io/v1
128107
kind: Issuer
129108
metadata:
130-
name: cluster-proxy-ca-issuer
109+
name: kind-ca-issuer
131110
namespace: open-cluster-management-addon
132111
spec:
133112
ca:
134-
secretName: cluster-proxy-ca-secret
113+
secretName: kind-cluster-ca
135114
---
136-
# Certificate for cluster-proxy-user-server
137-
# This creates a TLS certificate for the user server
138115
apiVersion: cert-manager.io/v1
139116
kind: Certificate
140117
metadata:
@@ -154,7 +131,7 @@ spec:
154131
algorithm: RSA
155132
size: 2048
156133
issuerRef:
157-
name: cluster-proxy-ca-issuer
134+
name: kind-ca-issuer
158135
kind: Issuer
159136
EOF
160137
```
@@ -174,7 +151,7 @@ Now install the cluster-proxy addon with the necessary configuration:
174151
# This is the Docker gateway IP that allows the Kind cluster to communicate with services
175152
# running on the host machine. The managed cluster will use this address to connect
176153
# to the proxy server running in the hub cluster.
177-
GATEWAY_IP="172.17.0.1"
154+
GATEWAY_IP=$(docker inspect hub-control-plane --format '{{.NetworkSettings.Networks.kind.IPAddress}}')
178155

179156
kubectl config use-context kind-hub
180157
helm install -n open-cluster-management-addon --create-namespace \

0 commit comments

Comments
 (0)