Skip to content

Commit 8c9b1bd

Browse files
authored
Merge pull request #45 from rifelpet/kops_documentation
Add documentation on using Authenticator with Kops
2 parents 226f7ba + c466dee commit 8c9b1bd

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,53 @@ The token is valid for 15 minutes (the shortest value AWS permits) and can be re
118118
You can also omit `-r ROLE_ARN` to sign the token with your existing credentials without assuming a dedicated role.
119119
This is useful if you want to authenticate as an IAM user directly or if you want to authenticate using an EC2 instance role or a federated role.
120120

121+
## Kops Usage
122+
Clusters managed by [Kops](https://github.com/kubernetes/kops) can be configured to use Authenticator.
123+
Both single and HA master cluster configurations are supported.
124+
Perform the following steps to setup Authenticator on a Kops cluster:
125+
1. Pre-generate the certificate, key, and kubeconfig and upload them to the kops state store.
126+
```
127+
heptio-authenticator-aws init -i $CLUSTER_NAME
128+
aws s3 cp cert.pem ${KOPS_STATE_STORE}/${CLUSTER_NAME}/addons/authenticator/cert.pem;
129+
aws s3 cp key.pem ${KOPS_STATE_STORE}/${CLUSTER_NAME}/addons/authenticator/key.pem;
130+
aws s3 cp heptio-authenticator-aws.kubeconfig ${KOPS_STATE_STORE}/${CLUSTER_NAME}/addons/authenticator/kubeconfig.yaml;
131+
```
132+
2. Add the following sections to the cluster spec, either using `kops edit cluster ${CLUSTER_NAME}` or editing the manifest yaml file.
133+
Be sure to replace `KOPS_STATE_STORE` and `CLUSTER_NAME` with their appropriate values since those environment variables are not available at runtime.
134+
This downloads the files from the state store on masters to a directory that is volume mounted by kube-apiserver.
135+
Kops does not support adding additional volumes to kube-apiserver so we must reuse the existing `/srv/kubernetes` hostPath volume.
136+
```
137+
apiVersion: kops/v1alpha2
138+
kind: Cluster
139+
spec:
140+
kubeAPIServer:
141+
authenticationTokenWebhookConfigFile: /srv/kubernetes/heptio-authenticator-aws/kubeconfig.yaml
142+
hooks:
143+
- name: kops-hook-authenticator-config.service
144+
before:
145+
- kubelet.service
146+
roles: [Master]
147+
manifest: |
148+
[Unit]
149+
Description=Download Heptio AWS Authenticator configs from S3
150+
[Service]
151+
Type=oneshot
152+
ExecStart=/bin/mkdir -p /srv/kubernetes/heptio-authenticator-aws
153+
ExecStart=/usr/local/bin/aws s3 cp --recursive s3://KOPS_STATE_STORE/CLUSTER_NAME/addons/authenticator /srv/kubernetes/heptio-authenticator-aws/
154+
```
155+
If using a non-default AMI that does not have the AWS CLI, replace the second ExecStart statement with
156+
157+
```
158+
ExecStart=/usr/bin/docker run --net=host --rm -v /srv/kubernetes/heptio-authenticator-aws:/srv/kubernetes/heptio-authenticator-aws quay.io/coreos/awscli@sha256:7b893bfb22ac582587798b011024f40871cd7424b9026595fd99c2b69492791d aws s3 cp --recursive s3://KOPS_STATE_STORE/CLUSTER_NAME/addons/authenticator /srv/kubernetes/heptio-authenticator-aws/
159+
```
160+
3. Apply the changes with `kops update cluster ${CLUSTER_NAME}`.
161+
If the cluster already exists, roll the cluster with `kops rolling-update cluster ${CLUSTER_NAME}` in order to recreate the master nodes.
162+
4. Update the Authenticator DaemonSet's state and output volumes to both use `/srv/kubernetes/heptio-authenticator-aws/` for their `hostPath`s.
163+
5. Apply the DaemonSet and ConfigMap resource manifests to launch the Authenticator server on the cluster.
164+
165+
*Note:* Certain Kops commands will overwrite the `ExecCredential` in kubeconfig so it may need to be restored manually. See [kubernetes/kops#5051](https://github.com/kubernetes/kops/issues/5051) for more information.
166+
167+
121168
## How does it work?
122169
It works using the AWS [`sts:GetCallerIdentity`](https://docs.aws.amazon.com/STS/latest/APIReference/API_GetCallerIdentity.html) API endpoint.
123170
This endpoint returns information about whatever AWS IAM credentials you use to connect to it.

0 commit comments

Comments
 (0)