Skip to content
This repository was archived by the owner on Apr 25, 2024. It is now read-only.

Commit 2857dc8

Browse files
403-admission-policy bugfixes to certificate generation instructions
1 parent 0e0272b commit 2857dc8

File tree

1 file changed

+11
-40
lines changed
  • 04-path-security-and-networking/403-admission-policy

1 file changed

+11
-40
lines changed

04-path-security-and-networking/403-admission-policy/readme.adoc

+11-40
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,6 @@ First, create the required OpenSSL configuration files. Put these in your curre
8787
directory; we will only use them once to generate certificates. You may discard
8888
them after running the `openssl` commands below.
8989

90-
*client.conf*
91-
```bash
92-
[req]
93-
req_extensions = v3_req
94-
distinguished_name = req_distinguished_name
95-
[req_distinguished_name]
96-
[ v3_req ]
97-
basicConstraints = CA:FALSE
98-
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
99-
extendedKeyUsage = clientAuth, serverAuth
100-
subjectAltName = @alt_names
101-
[alt_names]
102-
DNS.1 = opa.opa.cluster.svc.local
103-
```
104-
10590
*server.conf*
10691
```bash
10792
[req]
@@ -112,15 +97,9 @@ distinguished_name = req_distinguished_name
11297
basicConstraints = CA:FALSE
11398
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
11499
extendedKeyUsage = clientAuth, serverAuth
115-
subjectAltName = @alt_names
116-
[alt_names]
117-
DNS.1 = opa.opa.cluster.svc.local
118100
```
119101

120-
IMPORTANT: The subjectAltName/IP address in the certificate MUST match the one configured on the Kubernetes Service.
121-
122-
Now create local files that contain the CA and client/server key pairs. Shortly we will
123-
hand these keys to OPA and the API server so they can communicate.
102+
Now create local files that contain the CA and server key pair.
124103

125104
Create a certificate authority:
126105

@@ -132,35 +111,21 @@ openssl genrsa -out ca.key 2048
132111
openssl req -x509 -new -nodes -key ca.key -days 100000 -out ca.crt -subj "/CN=admission_ca"
133112
```
134113

135-
Create a server certiticate:
114+
Create a server certiticate.
115+
IMPORTANT: the CN must match the name of the service used to expose the external admission controller.
136116

137117
```bash
138118
openssl genrsa -out server.key 2048
139119
```
140120

141121
```bash
142-
openssl req -new -key server.key -out server.csr -subj "/CN=admission_server" -config server.conf
122+
openssl req -new -key server.key -out server.csr -subj "/CN=opa.opa.svc" -config server.conf
143123
```
144124

145125
```bash
146126
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 100000 -extensions v3_req -extfile server.conf
147127
```
148128

149-
Create a client certiticate:
150-
151-
```bash
152-
openssl genrsa -out client.key 2048
153-
```
154-
155-
```bash
156-
openssl req -new -key client.key -out client.csr -subj "/CN=admission_client" -config client.conf
157-
```
158-
159-
```bash
160-
openssl x509 -req -in client.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out client.crt -days 100000 -extensions v3_req -extfile client.conf
161-
```
162-
163-
164129
=== 2.2: Deploy OPA on Kubernetes
165130

166131
First, create a namespace to deploy OPA into.
@@ -238,9 +203,11 @@ spec:
238203
mountPath: /certs
239204
name: opa-server
240205
- name: kube-mgmt
241-
image: openpolicyagent/kube-mgmt:0.4
206+
image: openpolicyagent/kube-mgmt:0.5
242207
args:
243208
- "--replicate=v1/pods"
209+
- "--pod-name=$(MY_POD_NAME)"
210+
- "--pod-namespace=$(MY_POD_NAMESPACE)"
244211
- "--register-admission-controller"
245212
- "--admission-controller-ca-cert-file=/certs/ca.crt"
246213
- "--admission-controller-service-name=opa"
@@ -250,6 +217,10 @@ spec:
250217
mountPath: /certs
251218
name: opa-ca
252219
env:
220+
- name: MY_POD_NAME
221+
valueFrom:
222+
fieldRef:
223+
fieldPath: metadata.name
253224
- name: MY_POD_NAMESPACE
254225
valueFrom:
255226
fieldRef:

0 commit comments

Comments
 (0)