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

ingress: Create Ingress Service if required #1404

Merged
merged 2 commits into from
Feb 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 33 additions & 1 deletion install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (k *K8sInstaller) generateIngressClass() *networkingv1.IngressClass {

switch {
case versioncheck.MustCompile(">=1.12.0")(k.chartVersion):
ingressFileName = "templates/cilium-operator-deployment.yaml"
ingressFileName = "templates/cilium-ingress-class.yaml"
}

ingressClassFile, exists := k.manifests[ingressFileName]
Expand All @@ -124,6 +124,26 @@ func (k *K8sInstaller) generateIngressClass() *networkingv1.IngressClass {
return &ingressClass
}

func (k *K8sInstaller) generateIngressService() *corev1.Service {
var (
ingressServiceFilename string
)

switch {
case versioncheck.MustCompile(">=1.13.0")(k.chartVersion):
ingressServiceFilename = "templates/cilium-ingress-service.yaml"
}

ingressServiceFile, exists := k.manifests[ingressServiceFilename]
if !exists {
return nil
}

var ingressService corev1.Service
utils.MustUnmarshalYAML([]byte(ingressServiceFile), &ingressService)
return &ingressService
}

func (k *K8sInstaller) getSecretNamespace() string {
var (
nsFilename string
Expand Down Expand Up @@ -782,6 +802,18 @@ func (k *K8sInstaller) Install(ctx context.Context) error {
})
}

ingressService := k.generateIngressService()
if ingressService != nil {
if _, err := k.client.CreateService(ctx, ingressService.GetNamespace(), ingressService, metav1.CreateOptions{}); err != nil {
return err
}
k.pushRollbackStep(func(ctx context.Context) {
if err := k.client.DeleteService(ctx, ingressService.GetNamespace(), ingressService.GetName(), metav1.DeleteOptions{}); err != nil {
k.Log("Cannot delete %s Ingress Service: %s.%s", ingressService.GetNamespace(), ingressService.GetName(), err)
}
})
}

secretsNamespace := k.getSecretNamespace()
if len(secretsNamespace) != 0 {
if _, err := k.client.CreateNamespace(ctx, secretsNamespace, metav1.CreateOptions{}); err != nil {
Expand Down