Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit d749164

Browse files
Saverio Protodims
authored andcommitted
Improve README
1 parent b195f81 commit d749164

1 file changed

Lines changed: 62 additions & 3 deletions

File tree

README.md

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,83 @@ preferences: {}
2323
users:
2424
- name: webhook
2525
```
26-
- Copy the examples/policy.json and edit it to your needs.
26+
27+
## Configuration on K8s master for authentication
28+
2729
- Add the following flags to your Kubernetes api server.
2830
* `--authentication-token-webhook-config-file=/path/to/your/webhook.kubeconfig`
29-
* `--authorization-mode=Webhook --authorization-webhook-config-file=/path/to/your/webhook.kubeconfig`
31+
* `--authorization-mode=Node,RBAC`
3032
- Start webhook process with the following flags
3133
* `--tls-cert-file /var/run/kubernetes/serving-kube-apiserver.crt`
3234
* `--tls-private-key-file /var/run/kubernetes/serving-kube-apiserver.key`
3335
* `--keystone-policy-file examples/policy.json`
36+
* `--keystone-url https://my.keystone:5000/v3`
37+
38+
## Configuration on K8s master for authorization
39+
40+
- Copy the examples/policy.json and edit it to your needs.
41+
- Add the following flags to your Kubernetes api server.
42+
* `--authorization-mode=Webhook,Node --authorization-webhook-config-file=/path/to/your/webhook.kubeconfig`
43+
- When you start the webhook process make sure you also have the following flags (in addition to the flags in the case of authentication)
44+
* `--keystone-policy-file examples/policy.json`
45+
46+
## K8s kubectl Client configuration
47+
48+
### Old kubectl clients
49+
3450
- Run `openstack token issue` to generate a token
3551
- Run `kubectl --token $TOKEN get po` or `curl -k -v -XGET -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" https://localhost:6443/api/v1/namespaces/default/pods`
3652

53+
### New kubectl clients v1.8.0 and later
54+
55+
The client is able to read the `OS_` env variables used also by the openstackclient. You dont have to pass a token with `--token`, but the client will contact Keystone directly, will get a token and will use it. To configure the client to the following:
56+
57+
- Run `kubectl config set-credentials openstackuser --auth-provider=openstack`
58+
59+
This command creates the following entry in your ~/.kube/config
60+
```
61+
- name: openstackuser
62+
user:
63+
as-user-extra: {}
64+
auth-provider:
65+
name: openstack
66+
```
67+
- Run `kubectl config set-context --cluster=kubernetes --user=openstackuser openstackuser@kubernetes`
68+
- Run `kubectl config use-context openstackuser@kubernetes` to activate the context
69+
70+
Source your env vars. Make sure you include `OS_DOMAIN_NAME` or the client will fallback to Keystone V2 that is not supported by the webhook.This env should be ok:
71+
72+
```
73+
OS_AUTH_URL="https://keystone.example.com:5000/v3"
74+
OS_DOMAIN_NAME="default"
75+
OS_IDENTITY_API_VERSION="3"
76+
OS_PASSWORD="mysecret"
77+
OS_PROJECT_NAME="myproject"
78+
OS_REGION_NAME="myRegion"
79+
OS_USERNAME="username"
80+
```
81+
- Try: `kubectl get pods`
82+
83+
In case you are using this Webhook just for the authentication, you should get an authorization error:
84+
```
85+
Error from server (Forbidden): pods is forbidden: User "username" cannot list pods in the namespace "default"
86+
```
87+
88+
You need to configure the RBAC with roles to be authorized to do something, for example:
89+
90+
``` kubectl create rolebinding username-view --clusterrole view --user username --namespace default```
91+
92+
Try now again to see the pods with `kubectl get pods`
93+
94+
## References
95+
3796
More details about Kubernetes Authentication Webhook using Bearer Tokens is at :
3897
https://kubernetes.io/docs/admin/authentication/#webhook-token-authentication
3998

4099
and the Authorization Webhook is at:
41100
https://kubernetes.io/docs/admin/authorization/webhook/
42101

43-
Tips:
102+
## Tips
44103

45104
- You can directly test the webhook with
46105
```

0 commit comments

Comments
 (0)