Skip to content
This repository was archived by the owner on Jan 8, 2026. It is now read-only.

Commit 5f56a68

Browse files
authored
fix: README.md, gen_cert.sh, deployment.yaml (#35)
* fix: README.md, gen_cert.sh, deployment.yaml * fix: README.md, gen_cert.sh, deployment.yaml * fix: README.md, gen_cert.sh, deployment.yaml
1 parent a57a7e9 commit 5f56a68

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,26 @@ Before proceeding, make sure to have the following-
3333
```
3434
./gen_cert.sh
3535
```
36+
- Export environment variable `CA_BUNDLE`
37+
```
38+
export CA_BUNDLE=$(cat certs/ca.crt | base64 | tr -d '\n')
39+
```
40+
- Use `envsubst` to pass environment variables to `deployment.yaml.template`, generating `deployment.yaml`
41+
```
42+
cat manifests/deployment.yaml.template | envsubst > manifests/deployment.yaml
43+
```
44+
45+
3646
- Build the docker image from the [Dockerfile](https://github.com/casbin/k8s-authz/blob/master/Dockerfile) manually by running the following command and then change the build version here and at the deployment [file](https://github.com/casbin/k8s-authz/blob/718f58c46e3dbf79063b5b1c18348c2fee5de9e9/manifests/deployment.yaml#L18), as per the builds.
3747
```
38-
docker build -t casbin/k8s_authz:0.1 .
48+
docker build -t casbin/k8s_authz:latest .
3949
```
4050
- Define the casbin policies in the [model.conf](https://github.com/casbin/k8s-authz/blob/master/config/model.conf) and [policy.csv](https://github.com/casbin/k8s-authz/blob/master/config/policy.csv). You can refer the [docs](https://casbin.org/docs/how-it-works) to get to know more about the working of these policies.
4151

4252
- Before deploying, you can change the ports in [main.go](https://github.com/casbin/k8s-authz/blob/master/main.go) and also in the validation webhook configuration [file](https://github.com/casbin/k8s-authz/blob/master/manifests/deployment.yaml) depending on your usage.
4353
- Deploy the validation controller and the webhook on k8s cluster by running:-
4454
```
45-
kubectl apply -f deployment.yaml
55+
kubectl apply -f manifests/deployment.yaml
4656
```
4757
- For a production server, we need to create a k8s `secret` to place the certificates for security purposes.
4858
```

gen_cert.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,4 @@ openssl genrsa -out certs/casbin-key.pem 2048
1212

1313
openssl req -new -key certs/casbin-key.pem -subj "/CN=casbin.default.svc" -out casbin.csr
1414

15-
openssl x509 -req -in casbin.csr -CA certs/ca.crt -CAkey certs/ca.key -CAcreateserial -out certs/casbin-crt.pem
16-
17-
export CA_BUNDLE=$(cat certs/ca.crt | base64 | tr -d '\n')
18-
cat deployment.yaml | envsubst > deployment.yaml
15+
openssl x509 -req -in casbin.csr -CA certs/ca.crt -CAkey certs/ca.key -CAcreateserial -out certs/casbin-crt.pem
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ spec:
4848
port: 443
4949
targetPort: 8080
5050
selector:
51-
name: casbin
51+
name: casbin
5252
---
5353
apiVersion: admissionregistration.k8s.io/v1
5454
kind: ValidatingWebhookConfiguration
5555
metadata:
5656
name: casbin
5757
webhooks:
58-
- name: casbin.org
58+
- name: webhook.casbin.org
5959
clientConfig:
6060
service:
61-
name: server
61+
name: casbin
6262
namespace: default
6363
path: "/validate"
6464
caBundle: "${CA_BUNDLE}"
@@ -68,3 +68,5 @@ webhooks:
6868
apiVersions: ["v1"]
6969
resources: ["*/*"]
7070
failurePolicy: Fail
71+
admissionReviewVersions: ["v1"]
72+
sideEffects: None

0 commit comments

Comments
 (0)