Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1892 from dominicgunn/feature/kiam-updates
Browse files Browse the repository at this point in the history
[v0.16.x] KIAM updates to support assumeRoleArn functionalilty
  • Loading branch information
dominicgunn authored Aug 25, 2020
2 parents b06335b + 74d6610 commit d1681b6
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 92 deletions.
1 change: 1 addition & 0 deletions builtin/files/cluster.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,7 @@ kubeAwsPlugins:
# image: quay.io/uswitch/kiam
# tag: v3.2
# sessionDuration: 30m
# assumeRoleArn: arn:aws:iam::....
# server:
# portName: grpclb
# address: localhost:443
Expand Down
47 changes: 19 additions & 28 deletions builtin/files/plugins/kiam/manifests/agent-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ metadata:
namespace: kube-system
name: kiam-agent
spec:
updateStrategy:
rollingUpdate:
maxUnavailable: 100%
type: RollingUpdate
selector:
matchLabels:
app: kiam
role: agent
updateStrategy:
type: OnDelete
template:
metadata:
annotations:
Expand All @@ -21,41 +19,32 @@ spec:
app: kiam
role: agent
spec:
priorityClassName: system-node-critical
tolerations:
- operator: Exists
effect: NoSchedule
- operator: Exists
effect: NoExecute
- operator: Exists
key: CriticalAddonsOnly
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node.kubernetes.io/role
operator: NotIn
values:
- master
nodeSelector:
kubernetes.io/role: node
volumes:
- name: ssl-certs
hostPath:
# for AWS linux or RHEL distros
# path: /etc/pki/ca-trust/extracted/pem/
# debian or ubuntu distros
# path: /etc/ssl/certs
path: /usr/share/ca-certificates
- name: tls
secret:
secretName: kiam-agent-tls
- name: xtables
hostPath:
path: /run/xtables.lock
type: FileOrCreate
containers:
- name: kiam
securityContext:
capabilities:
add: ["NET_ADMIN"]
image: {{ .Values.image }}:{{ .Values.tag }}
imagePullPolicy: Always
command:
- {{ if checkVersion ">= 3.0" .Values.tag }}/kiam{{ else }}/agent{{ end }}
args:
Expand All @@ -65,18 +54,20 @@ spec:
- --gateway-timeout-creation=1s
{{ end -}}
- --iptables
{{- if .Config.Cluster.Kubernetes.Networking.AmazonVPC.Enabled }}
{{- if .Config.Cluster.Kubernetes.Networking.AmazonVPC.Enabled }}
- --host-interface=!eni0
{{- else if eq .Config.Cluster.Kubernetes.Networking.SelfHosting.Type "canal" }}
{{- else if eq .Config.Cluster.Kubernetes.Networking.SelfHosting.Type "canal" }}
- --host-interface=cali+
{{- else if eq .Config.Cluster.Kubernetes.Networking.SelfHosting.Type "calico" }}
- --host-interface=cali+
{{- else}}
{{- else}}
- --host-interface=cni0
{{- end }}
{{- end }}
- --json-log
- --port=8181
- --cert=/etc/kiam/tls/tls.crt
- --key=/etc/kiam/tls/tls.key
- --ca=/etc/kiam/tls/ca.crt
- --cert=/etc/kiam/tls/agent.pem
- --key=/etc/kiam/tls/agent-key.pem
- --ca=/etc/kiam/tls/ca.pem
- --server-address={{ .Values.agent.address }}
- --prometheus-listen-addr=0.0.0.0:9620
- --prometheus-sync-interval=5s
Expand Down
8 changes: 4 additions & 4 deletions builtin/files/plugins/kiam/manifests/agent-tls-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ kind: Secret
metadata:
name: kiam-agent-tls
namespace: kube-system
type: kubernetes.io/tls
type: Opaque
data:
tls.crt: {{ insertTemplateFile "credentials/kiam-agent.pem" . | b64enc }}
tls.key: {{ insertTemplateFile "credentials/kiam-agent-key.pem" . | b64enc }}
ca.crt: {{ insertTemplateFile "credentials/kiam-ca.pem" . | b64enc }}
agent.pem: {{ insertTemplateFile "credentials/kiam-agent.pem" . | b64enc }}
agent-key.pem: {{ insertTemplateFile "credentials/kiam-agent-key.pem" . | b64enc }}
ca.pem: {{ insertTemplateFile "credentials/kiam-ca.pem" . | b64enc }}
60 changes: 60 additions & 0 deletions builtin/files/plugins/kiam/manifests/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
kind: ServiceAccount
apiVersion: v1
metadata:
name: kiam-server
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: kiam-read
rules:
- apiGroups:
- ""
resources:
- namespaces
- pods
verbs:
- watch
- get
- list
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: kiam-read
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kiam-read
subjects:
- kind: ServiceAccount
name: kiam-server
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: kiam-write
rules:
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: kiam-write
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kiam-write
subjects:
- kind: ServiceAccount
name: kiam-server
namespace: kube-system

This file was deleted.

21 changes: 0 additions & 21 deletions builtin/files/plugins/kiam/manifests/server-cluster-role.yaml

This file was deleted.

21 changes: 12 additions & 9 deletions builtin/files/plugins/kiam/manifests/server-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ spec:
{{ end -}}
- --json-log
- --bind=0.0.0.0:443
- --cert=/etc/kiam/tls/tls.crt
- --key=/etc/kiam/tls/tls.key
- --ca=/etc/kiam/tls/ca.crt
- --cert=/etc/kiam/tls/server.pem
- --key=/etc/kiam/tls/server-key.pem
- --ca=/etc/kiam/tls/ca.pem
- --role-base-arn-autodetect
{{- if .Values.assumeRoleArn }}
- --assume-role-arn={{ .Values.assumeRoleArn }}
{{- end }}
- --sync=1m
- --prometheus-listen-addr=0.0.0.0:9620
- --prometheus-sync-interval=5s
Expand All @@ -74,9 +77,9 @@ spec:
- /health
- --server-address-refresh=2s
{{ end -}}
- --cert=/etc/kiam/tls/tls.crt
- --key=/etc/kiam/tls/tls.key
- --ca=/etc/kiam/tls/ca.crt
- --cert=/etc/kiam/tls/server.pem
- --key=/etc/kiam/tls/server-key.pem
- --ca=/etc/kiam/tls/ca.pem
- --server-address={{ .Values.server.address }}
- --timeout=5s
initialDelaySeconds: 10
Expand All @@ -93,9 +96,9 @@ spec:
- /health
- --server-address-refresh=2s
{{ end -}}
- --cert=/etc/kiam/tls/tls.crt
- --key=/etc/kiam/tls/tls.key
- --ca=/etc/kiam/tls/ca.crt
- --cert=/etc/kiam/tls/server.pem
- --key=/etc/kiam/tls/server-key.pem
- --ca=/etc/kiam/tls/ca.pem
- --server-address={{ .Values.server.address }}
- --timeout=5s
initialDelaySeconds: 3
Expand Down
8 changes: 4 additions & 4 deletions builtin/files/plugins/kiam/manifests/server-tls-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ kind: Secret
metadata:
name: kiam-server-tls
namespace: kube-system
type: kubernetes.io/tls
type: Opaque
data:
tls.crt: {{ insertTemplateFile "credentials/kiam-server.pem" . | b64enc }}
tls.key: {{ insertTemplateFile "credentials/kiam-server-key.pem" . | b64enc }}
ca.crt: {{ insertTemplateFile "credentials/kiam-ca.pem" . | b64enc }}
server.pem: {{ insertTemplateFile "credentials/kiam-server.pem" . | b64enc }}
server-key.pem: {{ insertTemplateFile "credentials/kiam-server-key.pem" . | b64enc }}
ca.pem: {{ insertTemplateFile "credentials/kiam-ca.pem" . | b64enc }}
5 changes: 0 additions & 5 deletions builtin/files/plugins/kiam/manifests/service-account.yaml

This file was deleted.

13 changes: 4 additions & 9 deletions builtin/files/plugins/kiam/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ spec:
image: quay.io/uswitch/kiam
tag: v3.2
sessionDuration: 30m
assumeRoleArn: ""
server:
portName: grpclb
address: localhost:443
Expand Down Expand Up @@ -40,11 +41,7 @@ spec:
- source:
path: manifests/service.yaml
- source:
path: manifests/service-account.yaml
- source:
path: manifests/server-cluster-role.yaml
- source:
path: manifests/server-cluster-role-binding.yaml
path: manifests/rbac.yaml

pki:
keypairs:
Expand All @@ -58,11 +55,9 @@ spec:
commonName: kiam-server
organization: kube-aws-kiam
dnsNames:
- kiam-server
- kiam-server:443
- localhost
- localhost:443
- localhost:9610
- 127.0.0.1
- kiam-server
duration: 8760h
usages:
- server
Expand Down

0 comments on commit d1681b6

Please sign in to comment.