@@ -87,21 +87,6 @@ First, create the required OpenSSL configuration files. Put these in your curre
87
87
directory; we will only use them once to generate certificates. You may discard
88
88
them after running the `openssl` commands below.
89
89
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
-
105
90
*server.conf*
106
91
```bash
107
92
[req]
@@ -112,15 +97,9 @@ distinguished_name = req_distinguished_name
112
97
basicConstraints = CA:FALSE
113
98
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
114
99
extendedKeyUsage = clientAuth, serverAuth
115
- subjectAltName = @alt_names
116
- [alt_names]
117
- DNS.1 = opa.opa.cluster.svc.local
118
100
```
119
101
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.
124
103
125
104
Create a certificate authority:
126
105
@@ -132,35 +111,21 @@ openssl genrsa -out ca.key 2048
132
111
openssl req -x509 -new -nodes -key ca.key -days 100000 -out ca.crt -subj "/CN=admission_ca"
133
112
```
134
113
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.
136
116
137
117
```bash
138
118
openssl genrsa -out server.key 2048
139
119
```
140
120
141
121
```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
143
123
```
144
124
145
125
```bash
146
126
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 100000 -extensions v3_req -extfile server.conf
147
127
```
148
128
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
-
164
129
=== 2.2: Deploy OPA on Kubernetes
165
130
166
131
First, create a namespace to deploy OPA into.
@@ -238,9 +203,11 @@ spec:
238
203
mountPath: /certs
239
204
name: opa-server
240
205
- name: kube-mgmt
241
- image: openpolicyagent/kube-mgmt:0.4
206
+ image: openpolicyagent/kube-mgmt:0.5
242
207
args:
243
208
- "--replicate=v1/pods"
209
+ - "--pod-name=$(MY_POD_NAME)"
210
+ - "--pod-namespace=$(MY_POD_NAMESPACE)"
244
211
- "--register-admission-controller"
245
212
- "--admission-controller-ca-cert-file=/certs/ca.crt"
246
213
- "--admission-controller-service-name=opa"
@@ -250,6 +217,10 @@ spec:
250
217
mountPath: /certs
251
218
name: opa-ca
252
219
env:
220
+ - name: MY_POD_NAME
221
+ valueFrom:
222
+ fieldRef:
223
+ fieldPath: metadata.name
253
224
- name: MY_POD_NAMESPACE
254
225
valueFrom:
255
226
fieldRef:
0 commit comments