Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chainrole - service account annotations as source of session configuration #13

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions charts/eks-pod-identity-agent/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.deployment.enabled }}
apiVersion: apps/v1
kind: DaemonSet
metadata:
Expand Down Expand Up @@ -123,3 +124,4 @@ spec:
initialDelaySeconds: 1
timeoutSeconds: 10
{{- end }}
{{- end }}
102 changes: 102 additions & 0 deletions charts/eks-pod-identity-agent/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{{- if .Values.deployment.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "eks-pod-identity-agent.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "eks-pod-identity-agent.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "eks-pod-identity-agent.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "eks-pod-identity-agent.selectorLabels" . | nindent 8 }}
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
priorityClassName: {{ .Values.priorityClassName }}
{{- if .Values.irsa.enabled }}
serviceAccountName: {{ include "eks-pod-identity-agent.fullname" . }}
{{- end }}
terminationGracePeriodSeconds: 30
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: {{ include "eks-pod-identity-agent.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: {{ .Values.agent.command }}
args:
- "--port"
- {{ .Values.deployment.port | quote }}
- "--cluster-name"
- {{ .Values.clusterName | quote }}
- "--probe-port"
- {{ .Values.agent.probePort | quote }}
{{- if .Values.metrics.enabled }}
- "--metrics-port"
- {{ .Values.metrics.port | quote }}
{{- end }}
{{- range $key, $value := .Values.agent.additionalArgs }}
- {{ $key | quote }}
- {{ $value | quote }}
{{- end }}
ports:
- containerPort: {{ .Values.deployment.port }}
protocol: TCP
name: http
- containerPort: {{ .Values.agent.probePort }}
protocol: TCP
name: probes-port
{{- if .Values.metrics.enabled }}
- containerPort: {{ .Values.metrics.port }}
protocol: TCP
name: metrics
{{- end }}
env:
{{- range $key, $value := .Values.env }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if .Values.agent.livenessEndpoint }}
livenessProbe:
failureThreshold: 3
httpGet:
path: {{ .Values.agent.livenessEndpoint }}
port: probes-port
scheme: HTTP
initialDelaySeconds: 30
timeoutSeconds: 10
{{- end }}
{{- if .Values.agent.readinessEndpoint }}
readinessProbe:
failureThreshold: 30
httpGet:
path: {{ .Values.agent.readinessEndpoint }}
port: probes-port
scheme: HTTP
initialDelaySeconds: 1
timeoutSeconds: 10
{{- end }}
{{- end}}
20 changes: 0 additions & 20 deletions charts/eks-pod-identity-agent/templates/metrics.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
{{- if .Values.metrics.enabled -}}
---
apiVersion: v1
kind: Service
metadata:
name: eks-pod-identity-agent
namespace: {{ .Release.Namespace }}
labels:
{{- include "eks-pod-identity-agent.labels" . | nindent 4 }}
{{- with .Values.metrics.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
{{- include "eks-pod-identity-agent.selectorLabels" . | nindent 4 }}
ports:
- name: metrics
port: {{ .Values.metrics.port }}
targetPort: {{ .Values.metrics.port }}
type: ClusterIP

---
{{- if .Values.metrics.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
Expand Down
25 changes: 25 additions & 0 deletions charts/eks-pod-identity-agent/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.service.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "eks-pod-identity-agent.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "eks-pod-identity-agent.labels" . | nindent 4 }}
{{- with .Values.metrics.extraLabels -}}
{{ toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
name: http
{{- if .Values.metrics.enabled }}
- name: metrics
port: {{ .Values.metrics.port }}
targetPort: {{ .Values.metrics.port }}
{{- end}}
selector:
{{- include "eks-pod-identity-agent.selectorLabels" . | nindent 4 }}
{{- end }}
36 changes: 35 additions & 1 deletion charts/eks-pod-identity-agent/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,38 @@ metadata:
{{- with .Values.irsa.service_account.additionalAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}
{{- if .Values.irsa.cluster_role.enabled }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "eks-pod-identity-agent.fullname" . }}
rules:
{{- if .Values.irsa.cluster_role.permissions.serviceaccounts.verbs }}
- apiGroups: [""]
resources: ["serviceaccounts"]
verbs: {{ .Values.irsa.cluster_role.permissions.serviceaccounts.verbs }}
{{- end }}
{{- if .Values.irsa.cluster_role.permissions.tokenreviews.verbs }}
- apiGroups: ["authentication.k8s.io"]
resources: ["tokenreviews"]
verbs: {{ .Values.irsa.cluster_role.permissions.tokenreviews.verbs }}
{{- end }}
{{- with .Values.irsa.cluster_role.permissions.additionalRules }}
{{ toYaml . }}
{{- end }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "eks-pod-identity-agent.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "eks-pod-identity-agent.fullname" . }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ include "eks-pod-identity-agent.fullname" . }}
apiGroup: rbac.authorization.k8s.io
{{- end }}
{{- end -}}
17 changes: 17 additions & 0 deletions charts/eks-pod-identity-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,20 @@ irsa:
service_account:
role_arn: IRSA_ROLE_ARN
additionalAnnotations:
cluster_role:
enabled: false
permissions:
serviceaccounts:
verbs: ["get", "list", "watch"]
tokenreviews:
verbs: ["create"]
additionalRules: []

deployment:
enabled: false
port: 80

service:
enabled: false
type: ClusterIP
port: 80
35 changes: 32 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ require (
go.uber.org/mock v0.3.0
golang.org/x/sys v0.25.0
golang.org/x/time v0.3.0
k8s.io/api v0.31.1
k8s.io/apimachinery v0.31.1
k8s.io/client-go v0.31.1
)

require (
Expand All @@ -33,21 +36,47 @@ require (
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading
Loading