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

Hostnetwork #380

Merged
merged 3 commits into from
Mar 29, 2021
Merged
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 documentation/deploy_grafana.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ spec:
...
envFrom: # Environment variables from Secret or ConfigMap. The key of data becomes the env name.
...
hostNetwork: <bool> # hostNetwork option, DNSPolicy will be accordingly changed (ClusterFirst by default and ClusterFirstWithHostNet for hostNetwork: true)
...
skipCreateAdminAccount: <bool> # Skip creating the admin account when providing custom credentials from a secret.
...
priorityClassName: <string> # Assign a priorityClass name to the grafana pod. Empty by default.
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/integreatly/v1alpha1/grafana_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ type GrafanaDeployment struct {
EnvFrom []v1.EnvFromSource `json:"envFrom,omitempty"`
SkipCreateAdminAccount *bool `json:"skipCreateAdminAccount,omitempty"`
PriorityClassName string `json:"priorityClassName,omitempty"`
HostNetwork *bool `json:"hostNetwork,omitempty"`
}

// GrafanaIngress provides a means to configure the ingress created
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/integreatly/v1alpha1/zz_generated.deepcopy.go

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

17 changes: 17 additions & 0 deletions pkg/controller/model/grafanaDeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ func getSkipCreateAdminAccount(cr *v1alpha1.Grafana) bool {
return false
}

func getHostNetwork(cr *v1alpha1.Grafana) bool {
if cr.Spec.Deployment != nil && cr.Spec.Deployment.HostNetwork != nil {
return *cr.Spec.Deployment.HostNetwork
}

return false
}

func getDNSPolicy(cr *v1alpha1.Grafana) v13.DNSPolicy {
if getHostNetwork(cr) == true {
return "ClusterFirstWithHostNet"
}
return "ClusterFirst"
}

func getInitResources(cr *v1alpha1.Grafana) v13.ResourceRequirements {
if cr.Spec.InitResources != nil {
return *cr.Spec.InitResources
Expand Down Expand Up @@ -553,6 +568,8 @@ func getDeploymentSpec(cr *v1alpha1.Grafana, annotations map[string]string, conf
Tolerations: getTolerations(cr),
Affinity: getAffinities(cr),
SecurityContext: getSecurityContext(cr),
HostNetwork: getHostNetwork(cr),
DNSPolicy: getDNSPolicy(cr),
Volumes: getVolumes(cr),
InitContainers: getInitContainers(cr, plugins),
Containers: getContainers(cr, configHash, dsHash),
Expand Down