Skip to content

Commit

Permalink
feat: add nodeSelector to Chart and k8sgpt-operator (#292)
Browse files Browse the repository at this point in the history
Signed-off-by: tozastation <tozastation@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
  • Loading branch information
tozastation and AlexsJones committed Dec 20, 2023
1 parent fe4a5da commit c008d22
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 8 deletions.
17 changes: 9 additions & 8 deletions api/v1alpha1/k8sgpt_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ type Integrations struct {
type K8sGPTSpec struct {
Version string `json:"version,omitempty"`
// +kubebuilder:default:=ghcr.io/k8sgpt-ai/k8sgpt
Repository string `json:"repository,omitempty"`
NoCache bool `json:"noCache,omitempty"`
Filters []string `json:"filters,omitempty"`
ExtraOptions *ExtraOptionsRef `json:"extraOptions,omitempty"`
Sink *WebhookRef `json:"sink,omitempty"`
AI *AISpec `json:"ai,omitempty"`
RemoteCache *RemoteCacheRef `json:"remoteCache,omitempty"`
Integrations *Integrations `json:"integrations,omitempty"`
Repository string `json:"repository,omitempty"`
NoCache bool `json:"noCache,omitempty"`
Filters []string `json:"filters,omitempty"`
ExtraOptions *ExtraOptionsRef `json:"extraOptions,omitempty"`
Sink *WebhookRef `json:"sink,omitempty"`
AI *AISpec `json:"ai,omitempty"`
RemoteCache *RemoteCacheRef `json:"remoteCache,omitempty"`
Integrations *Integrations `json:"integrations,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}

const (
Expand Down
6 changes: 6 additions & 0 deletions api/v1alpha1/k8sgpt_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ var _ = Describe("The test cases for the K8sGPT CRDs", func() {
Version: version,
Repository: repository,
NoCache: true,
NodeSelector: map[string]string{
"nodepool": "management",
},
},
}

Expand All @@ -88,6 +91,9 @@ var _ = Describe("The test cases for the K8sGPT CRDs", func() {
Repository: repository,
Version: version,
NoCache: false,
NodeSelector: map[string]string{
"nodepool": "management",
},
},
}

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.

3 changes: 3 additions & 0 deletions chart/operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ spec:
runAsNonRoot: true
serviceAccountName: {{ include "chart.fullname" . }}-controller-manager
terminationGracePeriodSeconds: 10
{{- if .Values.controllerManager.nodeSelector }}
nodeSelector: {{ toYaml .Values.controllerManager.nodeSelector | nindent 8 }}
{{- end }}
4 changes: 4 additions & 0 deletions chart/operator/templates/k8sgpt-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ spec:
type: object
noCache:
type: boolean
nodeSelector:
additionalProperties:
type: string
type: object
remoteCache:
properties:
azure:
Expand Down
4 changes: 4 additions & 0 deletions chart/operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ controllerManager:
cpu: 10m
memory: 64Mi
replicas: 1
## Node labels for pod assignment
## ref: https://kubernetes.io/docs/user-guide/node-selection/
#
nodeSelector: {}
kubernetesClusterDomain: cluster.local
metricsService:
ports:
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/core.k8sgpt.ai_k8sgpts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ spec:
type: object
noCache:
type: boolean
nodeSelector:
additionalProperties:
type: string
type: object
remoteCache:
properties:
azure:
Expand Down
1 change: 1 addition & 0 deletions pkg/resources/k8sgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ func GetDeployment(config v1alpha1.K8sGPT) (*appsv1.Deployment, error) {
Name: "k8sgpt-vol",
},
},
NodeSelector: config.Spec.NodeSelector,
},
},
},
Expand Down

0 comments on commit c008d22

Please sign in to comment.