Skip to content

Commit

Permalink
add global pod labels (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssz1997 authored Dec 4, 2023
1 parent 906fa87 commit bfd4ce0
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/v1alpha1/alluxiocluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type AlluxioClusterSpec struct {
DnsPolicy string `json:"dnsPolicy,omitempty" yaml:"dnsPolicy,omitempty"`
ServiceAccountName string `json:"serviceAccountName,omitempty" yaml:"serviceAccountName,omitempty"`
HostAliases []HostAlias `json:"hostAliases,omitempty" yaml:"hostAliases,omitempty"`
GlobalPodLabel map[string]string `json:"globalPodLabel,omitempty" yaml:"globalPodLabel,omitempty"`
HostPaths MountSpec `json:"hostPaths,omitempty" yaml:"hostPaths,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty" yaml:"nodeSelector,omitempty"`
Tolerations []Toleration `json:"tolerations,omitempty" yaml:"tolerations,omitempty"`
Expand Down Expand Up @@ -122,7 +123,7 @@ type PagestoreSpec struct {

type MetastoreSpec struct {
Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
HostPath *bool `json:"hostPath,omitempty" yaml:"hostPath,omitempty"`
HostPath string `json:"hostPath,omitempty" yaml:"hostPath,omitempty"`
Size string `json:"size,omitempty" yaml:"size,omitempty"`
StorageClass string `json:"storageClass,omitempty" yaml:"storageClass,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Expand Down
7 changes: 7 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,10 @@ spec:
user:
type: integer
type: object
globalPodLabel:
additionalProperties:
type: string
type: object
group:
type: integer
hostAliases:
Expand Down
3 changes: 3 additions & 0 deletions deploy/charts/alluxio/templates/csi/csi-fuse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ data:
name: {{ $fullName }}-fuse
app: {{ $name }}
role: alluxio-fuse
{{- if .Values.globalPodLabel }}
{{ toYaml .Values.globalPodLabel | trim | indent 8 }}
{{- end }}
spec:
securityContext:
runAsUser: {{ .Values.fuse.user }}
Expand Down
9 changes: 9 additions & 0 deletions deploy/charts/alluxio/templates/fuse/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-fuse
{{- if .Values.globalPodLabel }}
{{ toYaml .Values.globalPodLabel | trim | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
Expand All @@ -37,6 +40,9 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-fuse
{{- if .Values.globalPodLabel }}
{{ toYaml .Values.globalPodLabel | trim | indent 6 }}
{{- end }}
template:
metadata:
labels:
Expand All @@ -45,6 +51,9 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-fuse
{{- if .Values.globalPodLabel }}
{{ toYaml .Values.globalPodLabel | trim | indent 8 }}
{{- end }}
annotations:
{{- if .Values.fuse.podAnnotations }}
{{- toYaml .Values.fuse.podAnnotations | nindent 8 }}
Expand Down
9 changes: 9 additions & 0 deletions deploy/charts/alluxio/templates/master/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-master
{{- if .Values.globalPodLabel }}
{{ toYaml .Values.globalPodLabel | trim | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ $name }}
role: alluxio-master
name: {{ $fullName }}-master
{{- if .Values.globalPodLabel }}
{{ toYaml .Values.globalPodLabel | trim | indent 6 }}
{{- end }}
serviceName: {{ $fullName }}-master
replicas: {{ int .Values.master.count }}
template:
Expand All @@ -48,6 +54,9 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-master
{{- if .Values.globalPodLabel }}
{{ toYaml .Values.globalPodLabel | trim | indent 8 }}
{{- end }}
annotations:
{{- if .Values.master.podAnnotations }}
{{- toYaml .Values.master.podAnnotations | nindent 8 }}
Expand Down
9 changes: 9 additions & 0 deletions deploy/charts/alluxio/templates/proxy/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-proxy
{{- if .Values.globalPodLabel }}
{{ toYaml .Values.globalPodLabel | trim | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
Expand All @@ -36,6 +39,9 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-proxy
{{- if .Values.globalPodLabel }}
{{ toYaml .Values.globalPodLabel | trim | indent 6 }}
{{- end }}
template:
metadata:
labels:
Expand All @@ -45,6 +51,9 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-proxy
{{- if .Values.globalPodLabel }}
{{ toYaml .Values.globalPodLabel | trim | indent 8 }}
{{- end }}
annotations:
{{- if .Values.proxy.podAnnotations }}
{{- toYaml .Values.worker.podAnnotations | nindent 8 }}
Expand Down
9 changes: 9 additions & 0 deletions deploy/charts/alluxio/templates/worker/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: {{ $workerRoleName }}
{{- if .Values.globalPodLabel }}
{{ toYaml .Values.globalPodLabel | trim | indent 4 }}
{{- end }}
spec:
replicas: {{ .Values.worker.count }}
selector:
Expand All @@ -58,6 +61,9 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: {{ $workerRoleName }}
{{- if .Values.globalPodLabel }}
{{ toYaml .Values.globalPodLabel | trim | indent 6 }}
{{- end }}
strategy:
type: Recreate
template:
Expand All @@ -69,6 +75,9 @@ spec:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: {{ $workerRoleName }}
{{- if .Values.globalPodLabel }}
{{ toYaml .Values.globalPodLabel | trim | indent 8 }}
{{- end }}
annotations:
{{- if .Values.worker.podAnnotations }}
{{- toYaml .Values.worker.podAnnotations | nindent 8 }}
Expand Down
6 changes: 6 additions & 0 deletions deploy/charts/alluxio/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ serviceAccountName:
# - "example2.com"
hostAliases:

# Labels attached to all components of Alluxio. Format:
# globalPodLabel:
# <label key1>: <label value1>
# <label key2>: <label value2>
globalPodLabel:

# Use labels to run Alluxio on a subset of the K8s nodes. Format:
# nodeSelector:
# <lable key1>: <label value1>
Expand Down
4 changes: 4 additions & 0 deletions resources/crds/k8s-operator.alluxio.com_alluxioclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,10 @@ spec:
user:
type: integer
type: object
globalPodLabel:
additionalProperties:
type: string
type: object
group:
type: integer
hostAliases:
Expand Down
8 changes: 8 additions & 0 deletions tests/helm/config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ hostAliases:
- "example10.com"
- "example11.com"

# Labels attached to all components of Alluxio. Format:
# globalPodLabel:
# <label key1>: <label value1>
# <label key2>: <label value2>
globalPodLabel:
globalPodLabelKey1: globalPodLabelVal1
globalPodLabelKey2: globalPodLabelVal2

# Use labels to run Alluxio on a subset of the K8s nodes. Format:
# nodeSelector:
# <lable key1>: <label value1>
Expand Down
2 changes: 2 additions & 0 deletions tests/helm/expectedTemplates/csi/csi-fuse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ data:
name: dummy-alluxio-fuse
app: alluxio
role: alluxio-fuse
globalPodLabelKey1: globalPodLabelVal1
globalPodLabelKey2: globalPodLabelVal2
spec:
securityContext:
runAsUser: 1000
Expand Down
6 changes: 6 additions & 0 deletions tests/helm/expectedTemplates/fuse/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ metadata:
release: dummy
heritage: Helm
role: alluxio-fuse
globalPodLabelKey1: globalPodLabelVal1
globalPodLabelKey2: globalPodLabelVal2
spec:
selector:
matchLabels:
Expand All @@ -31,6 +33,8 @@ spec:
release: dummy
heritage: Helm
role: alluxio-fuse
globalPodLabelKey1: globalPodLabelVal1
globalPodLabelKey2: globalPodLabelVal2
template:
metadata:
labels:
Expand All @@ -39,6 +43,8 @@ spec:
release: dummy
heritage: Helm
role: alluxio-fuse
globalPodLabelKey1: globalPodLabelVal1
globalPodLabelKey2: globalPodLabelVal2
annotations:
proxyAnnotationKey1: fuseAnnotationVal1
proxyAnnotationKey2: fuseAnnotationVal2
Expand Down
6 changes: 6 additions & 0 deletions tests/helm/expectedTemplates/master/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ metadata:
release: dummy
heritage: Helm
role: alluxio-master
globalPodLabelKey1: globalPodLabelVal1
globalPodLabelKey2: globalPodLabelVal2
spec:
selector:
matchLabels:
app: alluxio
role: alluxio-master
name: dummy-alluxio-master
globalPodLabelKey1: globalPodLabelVal1
globalPodLabelKey2: globalPodLabelVal2
serviceName: dummy-alluxio-master
replicas: 3
template:
Expand All @@ -39,6 +43,8 @@ spec:
release: dummy
heritage: Helm
role: alluxio-master
globalPodLabelKey1: globalPodLabelVal1
globalPodLabelKey2: globalPodLabelVal2
annotations:
masterAnnotationKey1: masterAnnotationVal1
masterAnnotationKey2: masterAnnotationVal2
Expand Down
6 changes: 6 additions & 0 deletions tests/helm/expectedTemplates/proxy/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ metadata:
release: dummy
heritage: Helm
role: alluxio-proxy
globalPodLabelKey1: globalPodLabelVal1
globalPodLabelKey2: globalPodLabelVal2
spec:
selector:
matchLabels:
Expand All @@ -31,6 +33,8 @@ spec:
release: dummy
heritage: Helm
role: alluxio-proxy
globalPodLabelKey1: globalPodLabelVal1
globalPodLabelKey2: globalPodLabelVal2
template:
metadata:
labels:
Expand All @@ -40,6 +44,8 @@ spec:
release: dummy
heritage: Helm
role: alluxio-proxy
globalPodLabelKey1: globalPodLabelVal1
globalPodLabelKey2: globalPodLabelVal2
annotations:
workerAnnotationKey1: workerAnnotationVal1
workerAnnotationKey2: workerAnnotationVal2
Expand Down
6 changes: 6 additions & 0 deletions tests/helm/expectedTemplates/worker/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ metadata:
release: dummy
heritage: Helm
role: alluxio-worker
globalPodLabelKey1: globalPodLabelVal1
globalPodLabelKey2: globalPodLabelVal2
spec:
replicas: 2
selector:
Expand All @@ -32,6 +34,8 @@ spec:
release: dummy
heritage: Helm
role: alluxio-worker
globalPodLabelKey1: globalPodLabelVal1
globalPodLabelKey2: globalPodLabelVal2
strategy:
type: Recreate
template:
Expand All @@ -43,6 +47,8 @@ spec:
release: dummy
heritage: Helm
role: alluxio-worker
globalPodLabelKey1: globalPodLabelVal1
globalPodLabelKey2: globalPodLabelVal2
annotations:
workerAnnotationKey1: workerAnnotationVal1
workerAnnotationKey2: workerAnnotationVal2
Expand Down

0 comments on commit bfd4ce0

Please sign in to comment.