Skip to content

Commit

Permalink
Do not specify ingressClass. (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
axisofentropy authored Aug 16, 2023
1 parent 5776b8a commit 5e60421
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 58 deletions.
4 changes: 0 additions & 4 deletions controllers/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
)

func BuildVClusterIngress(helmReleaseName string, uCluster *v1alpha1.UffizziCluster) *v1.Ingress {
nginxIngressClass := INGRESS_CLASS_NGINX
uclusterIngressHost := BuildVClusterIngressHost(uCluster)
ingress := &v1.Ingress{
ObjectMeta: v12.ObjectMeta{
Expand All @@ -22,7 +21,6 @@ func BuildVClusterIngress(helmReleaseName string, uCluster *v1alpha1.UffizziClus
},
},
Spec: v1.IngressSpec{
IngressClassName: &nginxIngressClass,
Rules: []v1.IngressRule{
{
Host: uclusterIngressHost,
Expand Down Expand Up @@ -74,7 +72,6 @@ func BuildVClusterIngress(helmReleaseName string, uCluster *v1alpha1.UffizziClus

func BuildVClusterInternalServiceIngress(service v1alpha1.ExposedVClusterService, uCluster *v1alpha1.UffizziCluster, helmReleaseName string) *v1.Ingress {
const PATH = "/"
nginxIngressClass := INGRESS_CLASS_NGINX
internalServiceHost := BuildVClusterInternalServiceIngressHost(uCluster)
ingress := &v1.Ingress{
ObjectMeta: v12.ObjectMeta{
Expand All @@ -86,7 +83,6 @@ func BuildVClusterInternalServiceIngress(service v1alpha1.ExposedVClusterService
},
},
Spec: v1.IngressSpec{
IngressClassName: &nginxIngressClass,
Rules: []v1.IngressRule{
{
Host: internalServiceHost,
Expand Down
78 changes: 33 additions & 45 deletions controllers/uffizzicluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const (
VCLUSTER_CHART = "vcluster"
VCLUSTER_CHART_VERSION = "0.15.5"
LOFT_CHART_REPO_URL = "https://charts.loft.sh"
INGRESS_CLASS_NGINX = "nginx"
)

type LIFECYCLE_OP_TYPE string
Expand Down Expand Up @@ -171,31 +170,29 @@ func (r *UffizziClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reque
logger.Error(err, "Failed to create HelmRelease")
return ctrl.Result{}, err
}
// check if ingresses are enabled and if so create the ingress for the vcluster
if uCluster.Spec.Ingress.Class == INGRESS_CLASS_NGINX {
vclusterIngressHost := BuildVClusterIngressHost(uCluster) // r.createVClusterIngress(ctx, uCluster)
if err != nil {
logger.Error(err, "Failed to create ingress to vcluster internal service")
return ctrl.Result{}, err
}
// create the ingress for the vcluster
vclusterIngressHost := BuildVClusterIngressHost(uCluster) // r.createVClusterIngress(ctx, uCluster)
if err != nil {
logger.Error(err, "Failed to create ingress to vcluster internal service")
return ctrl.Result{}, err
}

uCluster.Status.Host = &vclusterIngressHost

uCluster.Status.Host = &vclusterIngressHost

// check if there are any services that need to be exposed from the vcluster
if uCluster.Spec.Ingress.Services != nil {
// Create the ingress for each service that is specified in the UffizziCluster services config
for _, service := range uCluster.Spec.Ingress.Services {
vclusterInternalServiceIngressStatus, err := r.createVClusterInternalServiceIngress(uCluster, service, ctx)
if err != nil {
logger.Error(err, "Failed to create ingress to vcluster internal service")
return ctrl.Result{}, err
}

// add the exposed service to the status
uCluster.Status.ExposedServices = append(uCluster.Status.ExposedServices,
*vclusterInternalServiceIngressStatus,
)
// check if there are any services that need to be exposed from the vcluster
if uCluster.Spec.Ingress.Services != nil {
// Create the ingress for each service that is specified in the UffizziCluster services config
for _, service := range uCluster.Spec.Ingress.Services {
vclusterInternalServiceIngressStatus, err := r.createVClusterInternalServiceIngress(uCluster, service, ctx)
if err != nil {
logger.Error(err, "Failed to create ingress to vcluster internal service")
return ctrl.Result{}, err
}

// add the exposed service to the status
uCluster.Status.ExposedServices = append(uCluster.Status.ExposedServices,
*vclusterInternalServiceIngressStatus,
)
}
}

Expand Down Expand Up @@ -332,20 +329,14 @@ func (r *UffizziClusterReconciler) upsertVClusterHelmRelease(update bool, ctx co
var (
VClusterIngressHostname = BuildVClusterIngressHost(uCluster)
OutKubeConfigServerArgValue = "https://" + VClusterIngressHostname
ingressClass = "uffizzi"
)

if uCluster.Spec.Ingress.Class != "" {
ingressClass = uCluster.Spec.Ingress.Class
}

uClusterHelmValues := VCluster{
Init: VClusterInit{},
FsGroup: 12345,
Ingress: VClusterIngress{
Enabled: true,
IngressClassName: ingressClass,
Host: VClusterIngressHostname,
Enabled: true,
Host: VClusterIngressHostname,
Annotations: map[string]string{
"app.uffizzi.com/ingress-sync": "true",
},
Expand Down Expand Up @@ -503,20 +494,17 @@ func (r *UffizziClusterReconciler) upsertVClusterHelmRelease(update bool, ctx co
// uClusterHelmValues.Sync.Ingresses.Enabled = *uCluster.Spec.Ingress.SyncFromManifests
//}

if uCluster.Spec.Ingress.Class == INGRESS_CLASS_NGINX {
uClusterHelmValues.Syncer.ExtraArgs = append(uClusterHelmValues.Syncer.ExtraArgs,
"--tls-san="+VClusterIngressHostname,
"--out-kube-config-server="+OutKubeConfigServerArgValue,
//"--out-kube-config-secret="+KubeConfigSecretName,
)
uClusterHelmValues.Syncer.ExtraArgs = append(uClusterHelmValues.Syncer.ExtraArgs,
"--tls-san="+VClusterIngressHostname,
"--out-kube-config-server="+OutKubeConfigServerArgValue,
)

if uCluster.Spec.Ingress.Services != nil {
for _, service := range uCluster.Spec.Ingress.Services {
uClusterHelmValues.MapServices.FromVirtual = append(uClusterHelmValues.MapServices.FromVirtual, VClusterMapServicesFromVirtual{
From: service.Namespace + "/" + service.Name,
To: helmReleaseName + "-" + service.Name,
})
}
if uCluster.Spec.Ingress.Services != nil {
for _, service := range uCluster.Spec.Ingress.Services {
uClusterHelmValues.MapServices.FromVirtual = append(uClusterHelmValues.MapServices.FromVirtual, VClusterMapServicesFromVirtual{
From: service.Namespace + "/" + service.Name,
To: helmReleaseName + "-" + service.Name,
})
}
}

Expand Down
1 change: 0 additions & 1 deletion examples/ingress-helm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
name: helm-basic
spec:
ingress:
class: "nginx"
host: deleteme2023.uffizzi.cloud
certManagerTLSEnabled: true
services:
Expand Down
1 change: 0 additions & 1 deletion examples/ingress-manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
namespace: quickstart-too
spec:
ingress:
class: "nginx"
host: uffizzi-client-clone-3.app.qa-gke.uffizzi.com
cluster:
ingressAnnotations:
Expand Down
3 changes: 1 addition & 2 deletions examples/ingress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- http:
paths:
Expand All @@ -15,4 +14,4 @@ spec:
service:
name: test
port:
number: 80
number: 80
3 changes: 0 additions & 3 deletions examples/manifest-basic-ingress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ spec:
enabled: false
ingress:
host: app.qa-gke.uffizzi.com
class: nginx
manifests: |
apiVersion: networking.k8s.io/v1
kind: Ingress
Expand All @@ -18,7 +17,6 @@ spec:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- http:
paths:
Expand All @@ -37,7 +35,6 @@ spec:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: whathostmost
http:
Expand Down
3 changes: 1 addition & 2 deletions examples/testnode-ucluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
name: testnode
spec:
# ingress:
# class: "nginx"
# host: deleteme2023.uffizzi.cloud
# services:
# - name: test-node-svc
Expand Down Expand Up @@ -32,4 +31,4 @@ spec:
namespace: test-node
values: |
image: dbpterraform2/test-node-zipofar:latest
app_port: 8080
app_port: 8080

0 comments on commit 5e60421

Please sign in to comment.