func GetNginxResources()

in pkg/manifests/nginx.go [60:96]


func GetNginxResources(conf *config.Config, ingressConfig *NginxIngressConfig) *NginxResources {
	if ingressConfig != nil && ingressConfig.Version == nil {
		ingressConfig.Version = &LatestNginxVersion
	}

	res := &NginxResources{
		IngressClass:            newNginxIngressControllerIngressClass(conf, ingressConfig),
		ServiceAccount:          newNginxIngressControllerServiceAccount(conf, ingressConfig),
		ClusterRole:             newNginxIngressControllerClusterRole(conf, ingressConfig),
		Role:                    newNginxIngressControllerRole(conf, ingressConfig),
		ClusterRoleBinding:      newNginxIngressControllerClusterRoleBinding(conf, ingressConfig),
		RoleBinding:             newNginxIngressControllerRoleBinding(conf, ingressConfig),
		Service:                 newNginxIngressControllerService(conf, ingressConfig),
		PromService:             newNginxIngressControllerPromService(conf, ingressConfig),
		Deployment:              newNginxIngressControllerDeployment(conf, ingressConfig),
		ConfigMap:               newNginxIngressControllerConfigmap(conf, ingressConfig),
		HorizontalPodAutoscaler: newNginxIngressControllerHPA(conf, ingressConfig),
		PodDisruptionBudget:     newNginxIngressControllerPDB(conf, ingressConfig),
	}

	switch ingressConfig.Version {
	// this doesn't do anything yet but when different versions have different resources we should change the resources here
	}

	for _, obj := range res.Objects() {
		l := util.MergeMaps(obj.GetLabels(), nginxLabels)
		obj.SetLabels(l)
	}

	// Can safely assume the namespace exists if using kube-system.
	// Purposefully do this after applying the labels, namespace isn't an Nginx-specific resource
	if conf.NS != "kube-system" {
		res.Namespace = Namespace(conf, conf.NS)
	}

	return res
}