|
| 1 | +AWS IAM Authenticator |
| 2 | +--------------------- |
| 3 | + |
| 4 | +`AWS IAM Authenticator <https://github.com/kubernetes-sigs/aws-iam-authenticator>`_ is a daemon that lets you authenticate to the |
| 5 | +Kubernetes RBAC system via Amazon Web Services - Identity and Access Management users and roles |
| 6 | + |
| 7 | +You can initialise the cluster to use this with the following configuration snippet in tarmak.yaml: |
| 8 | + |
| 9 | +.. code-block:: yaml |
| 10 | +
|
| 11 | + ... |
| 12 | + kubernetes: |
| 13 | + apiServer: |
| 14 | + amazon: |
| 15 | + awsIAMAuthenticatorInit: true |
| 16 | + ... |
| 17 | +
|
| 18 | +You can configure the IAM authenticator server with the following config map and daemonset, |
| 19 | +replacing ``000000000000`` with your AWS account ID and ``your-tarmak-cluster`` with your cluster name, |
| 20 | +including the ``-cluster`` suffix in a single cluster environment: |
| 21 | + |
| 22 | +.. code-block:: yaml |
| 23 | +
|
| 24 | + apiVersion: v1 |
| 25 | + kind: ConfigMap |
| 26 | + metadata: |
| 27 | + namespace: kube-system |
| 28 | + name: aws-iam-authenticator |
| 29 | + labels: |
| 30 | + k8s-app: aws-iam-authenticator |
| 31 | + data: |
| 32 | + config.yaml: | |
| 33 | + # a unique-per-cluster identifier to prevent replay attacks |
| 34 | + # (good choices are a random token or a domain name that will be unique to your cluster) |
| 35 | + clusterID: your-tarmak-cluster |
| 36 | + server: |
| 37 | + mapRoles: |
| 38 | + # statically map arn:aws:iam::<your account id>:role/KubernetesAdmin to a cluster admin |
| 39 | + - roleARN: arn:aws:iam::000000000000:role/KubernetesAdmin |
| 40 | + username: kubernetes-admin |
| 41 | + groups: |
| 42 | + - system:masters |
| 43 | + --- |
| 44 | + apiVersion: extensions/v1beta1 |
| 45 | + kind: DaemonSet |
| 46 | + metadata: |
| 47 | + namespace: kube-system |
| 48 | + name: aws-iam-authenticator |
| 49 | + labels: |
| 50 | + k8s-app: aws-iam-authenticator |
| 51 | + spec: |
| 52 | + updateStrategy: |
| 53 | + type: RollingUpdate |
| 54 | + template: |
| 55 | + metadata: |
| 56 | + annotations: |
| 57 | + scheduler.alpha.kubernetes.io/critical-pod: "" |
| 58 | + labels: |
| 59 | + k8s-app: aws-iam-authenticator |
| 60 | + spec: |
| 61 | + # run on the host network (don't depend on CNI) |
| 62 | + hostNetwork: true |
| 63 | + # run on each master node |
| 64 | + nodeSelector: |
| 65 | + node-role.kubernetes.io/master: "" |
| 66 | + tolerations: |
| 67 | + - effect: NoSchedule |
| 68 | + key: node-role.kubernetes.io/master |
| 69 | + - key: CriticalAddonsOnly |
| 70 | + operator: Exists |
| 71 | + containers: |
| 72 | + - name: aws-iam-authenticator |
| 73 | + image: 602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-iam-authenticator:v0.4.0-scratch |
| 74 | + args: |
| 75 | + - server |
| 76 | + - --config=/etc/aws-iam-authenticator/config.yaml |
| 77 | + - --state-dir=/var/aws-iam-authenticator |
| 78 | + - --generate-kubeconfig=/etc/kubernetes/aws-iam-authenticator/kubeconfig.yaml |
| 79 | + - --kubeconfig-pregenerated=true |
| 80 | + resources: |
| 81 | + requests: |
| 82 | + memory: 20Mi |
| 83 | + cpu: 10m |
| 84 | + limits: |
| 85 | + memory: 20Mi |
| 86 | + cpu: 100m |
| 87 | + securityContext: |
| 88 | + privileged: true |
| 89 | + volumeMounts: |
| 90 | + - name: config |
| 91 | + mountPath: /etc/aws-iam-authenticator/ |
| 92 | + - name: state |
| 93 | + mountPath: /var/aws-iam-authenticator/ |
| 94 | + securityContext: |
| 95 | + fsGroup: 0 |
| 96 | + runAsUser: 0 |
| 97 | + volumes: |
| 98 | + - name: config |
| 99 | + configMap: |
| 100 | + name: aws-iam-authenticator |
| 101 | + - name: state |
| 102 | + hostPath: |
| 103 | + path: /var/aws-iam-authenticator/ |
| 104 | +
|
| 105 | +You can then authenticate to the cluster with e.g. the following, as long as aws-iam-authenticator is |
| 106 | +downloaded and on your path: |
| 107 | + |
| 108 | +.. code-block:: yaml |
| 109 | +
|
| 110 | + apiVersion: v1 |
| 111 | + clusters: |
| 112 | + - cluster: |
| 113 | + certificate-authority-data: <snip - get these from ~/.tarmak/your-cluster/kubeconfig> |
| 114 | + server: https://api.your-cluster.somedomain.io ##see above |
| 115 | + name: your-cluster |
| 116 | + contexts: |
| 117 | + - context: |
| 118 | + cluster: your-cluster |
| 119 | + namespace: default |
| 120 | + user: your-cluster |
| 121 | + name: your-cluster |
| 122 | + users: |
| 123 | + - name: your-cluster |
| 124 | + user: |
| 125 | + exec: |
| 126 | + apiVersion: client.authentication.k8s.io/v1alpha1 |
| 127 | + args: |
| 128 | + - token |
| 129 | + - -i |
| 130 | + - your-cluster ##change me |
| 131 | + - -r |
| 132 | + - arn:aws:iam::000000000000:role/KubernetesAdmin ##change me |
| 133 | + command: aws-iam-authenticator-aws |
| 134 | + env: |
| 135 | + - name: AWS_PROFILE |
| 136 | + value: your_profile ##change or remove me |
0 commit comments