Skip to content

Commit

Permalink
Merge pull request #380 from alrf/hostnetwork
Browse files Browse the repository at this point in the history
Hostnetwork
  • Loading branch information
HVBE committed Mar 29, 2021
2 parents 5b7eee1 + 496569a commit cbe6716
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
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

0 comments on commit cbe6716

Please sign in to comment.