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

feat: Create new app for Gateway API #3057

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
97fecb0
feat: Create new app for Gateway API
shubham2g Jan 24, 2025
89ec410
feat: Create new app for Gateway API
shubham2g Jan 24, 2025
8b68156
feat: Work on comment
shubham2g Jan 24, 2025
4085279
feat: api version correction
shubham2g Jan 24, 2025
655510a
build: Updated .github/service-labeler.yaml
d2iq-mergebot Jan 24, 2025
bcd1498
feat: api version correction
shubham2g Jan 24, 2025
67caaa7
feat: Add independent management of Traefik CRDs
shubham2g Jan 27, 2025
4047924
feat: update kustomization.yaml
shubham2g Jan 27, 2025
2540d68
feat: worked on comment
shubham2g Jan 27, 2025
9ea137f
feat: include list-images-values.yaml
shubham2g Jan 28, 2025
cd205c5
feat: update the dir structure
shubham2g Jan 29, 2025
6fbd559
feat: worked on comment
shubham2g Jan 29, 2025
f4fa0fe
feat: kustomization file update
shubham2g Jan 29, 2025
3a87f65
feat: kustomization file update
shubham2g Jan 29, 2025
dc60e19
feat: apiversion update
shubham2g Jan 29, 2025
c8ff9d5
feat: changed the logic in apptests
shubham2g Jan 29, 2025
c009a58
feat: skip crds installtion
shubham2g Jan 29, 2025
97fc64d
feat: Add CRDs installation in apptests
shubham2g Jan 29, 2025
89ce66e
feat: Add traefik crd as dependency
shubham2g Jan 30, 2025
4200e86
feat: used absolutepath function
shubham2g Jan 30, 2025
0eaacfb
feat: corrected gateway api path
shubham2g Jan 30, 2025
f0b0a19
Merge branch 'main' into Shubham/Gateway-API-App
shubham2g Jan 30, 2025
2018bb2
feat: Added default CM
shubham2g Jan 30, 2025
a2c61b7
feat: path correction
shubham2g Jan 30, 2025
a6876d3
feat: print path to check
shubham2g Jan 30, 2025
158056a
feat: corrected path
shubham2g Jan 30, 2025
79f959a
feat: worked on comment
shubham2g Jan 30, 2025
32095b3
feat: changed the name as per comment
shubham2g Jan 30, 2025
cbbdfe5
fix(harbor): add gateway-api-crds default app
mhrabovcin Jan 30, 2025
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
4 changes: 4 additions & 0 deletions .github/service-labeler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ services/gatekeeper:
- changed-files:
- any-glob-to-any-file:
- services/gatekeeper/**
services/gateway-api-crds:
- changed-files:
- any-glob-to-any-file:
- services/gateway-api-crds/**
services/git-operator:
- changed-files:
- any-glob-to-any-file:
Expand Down
52 changes: 47 additions & 5 deletions apptests/appscenarios/traefik.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package appscenarios
import (
"context"
"fmt"
"os"
"path/filepath"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -58,13 +59,51 @@ func (t traefik) install(ctx context.Context, env *environment.Env, appPath stri
if err != nil {
return err
}
// apply the rest of kustomizations
err = env.ApplyKustomizations(ctx, appPath, map[string]string{
"releaseNamespace": kommanderNamespace,
"workspaceNamespace": kommanderNamespace,

// Find the correct versioned path for gateway-api-crds
gatewayCRDsPath, err := absolutePathTo("gateway-api-crds/1.2.0") // Ensure the correct version is used
mhrabovcin marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return fmt.Errorf("failed to get path for gateway-api-crds: %w", err)
}

// Apply defaults for gateway-api-crds
err = env.ApplyKustomizations(ctx, gatewayCRDsPath, map[string]string{
mhrabovcin marked this conversation as resolved.
Show resolved Hide resolved
"releaseNamespace": kommanderNamespace,
})
if err != nil {
return err
return fmt.Errorf("failed to apply defaults for gateway-api-crds: %w", err)
}

// Install gateway-api-crds
err = env.ApplyKustomizations(ctx, gatewayCRDsPath, map[string]string{
"releaseNamespace": kommanderNamespace,
})
if err != nil {
return fmt.Errorf("failed to apply gateway-api CRDs: %w", err)
}
// apply the rest of kustomizations
traefikDir := filepath.Join(appPath, "traefik")
if _, err := os.Stat(traefikDir); !os.IsNotExist(err) {
// If the traefik directory exists, apply both `crds` and `traefik` subdirectories
for _, dir := range []string{"crds", "traefik"} {
subDir := filepath.Join(appPath, dir)
err := env.ApplyKustomizations(ctx, subDir, map[string]string{
"releaseNamespace": kommanderNamespace,
"workspaceNamespace": kommanderNamespace,
})
if err != nil {
return err
}
}
} else {
// If the `traefik` directory doesn't exist, apply the default (root) kustomizations
err = env.ApplyKustomizations(ctx, appPath, map[string]string{
"releaseNamespace": kommanderNamespace,
"workspaceNamespace": kommanderNamespace,
})
if err != nil {
return err
}
}

traefikCMName := "traefik-overrides"
Expand Down Expand Up @@ -96,6 +135,9 @@ func (t traefik) install(ctx context.Context, env *environment.Env, appPath stri
hr.Spec.ValuesFrom = append(hr.Spec.ValuesFrom, fluxhelmv2beta2.ValuesReference{
Kind: "ConfigMap",
Name: traefikCMName,
}, fluxhelmv2beta2.ValuesReference{
Kind: "ConfigMap",
Name: "gateway-api-crds-defaults", // Ensure gateway-api-crds defaults are included
mhrabovcin marked this conversation as resolved.
Show resolved Hide resolved
})
return nil
})
Expand Down
12 changes: 12 additions & 0 deletions services/gateway-api-crds/1.2.0/defaults/cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: gateway-api-1.2.0-d2iq-defaults
namespace: ${releaseNamespace}
data:
values.yaml: |
# values.yaml content to enable only Gateway API CRDs installation
gatewayAPI: true
traefik: false
hub: false
deleteOnUninstall: false
4 changes: 4 additions & 0 deletions services/gateway-api-crds/1.2.0/defaults/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- cm.yaml
18 changes: 18 additions & 0 deletions services/gateway-api-crds/1.2.0/gateway-api-crds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: traefik-crds
mhrabovcin marked this conversation as resolved.
Show resolved Hide resolved
namespace: ${releaseNamespace}
spec:
interval: 6h
chart:
spec:
chart: traefik-crds
version: "1.2.0" # Use the appropriate version for Traefik CRDs
sourceRef:
kind: HelmRepository
name: helm.traefik.io-traefik
namespace: kommander-flux
valuesFrom:
- kind: ConfigMap
name: gateway-api-1.2.0-d2iq-defaults
4 changes: 4 additions & 0 deletions services/gateway-api-crds/1.2.0/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- gateway-api-crds.yaml
23 changes: 23 additions & 0 deletions services/traefik/34.1.0/crds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: traefik-crd-helmrelease
namespace: ${releaseNamespace}
spec:
force: false
prune: true
wait: true
interval: 6h
retryInterval: 1m
path: ./services/traefik/34.1.0/crds
sourceRef:
kind: GitRepository
name: management
namespace: kommander-flux
timeout: 1m
postBuild:
substitute:
releaseNamespace: ${releaseNamespace}
substituteFrom:
- kind: ConfigMap
name: substitution-vars
18 changes: 18 additions & 0 deletions services/traefik/34.1.0/crds/crds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
name: traefik-crds
namespace: ${releaseNamespace}
spec:
interval: 6h
chart:
spec:
chart: traefik-crds
version: "1.2.0" # Use the appropriate version for Traefik CRDs
sourceRef:
kind: HelmRepository
name: helm.traefik.io-traefik
namespace: kommander-flux
valuesFrom:
- kind: ConfigMap
name: traefik-crd-1.2.0-d2iq-defaults
4 changes: 4 additions & 0 deletions services/traefik/34.1.0/crds/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- crds.yaml
4 changes: 4 additions & 0 deletions services/traefik/34.1.0/crds/list-images-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gatewayAPI: false
traefik: true
hub: false
deleteOnUninstall: false
12 changes: 12 additions & 0 deletions services/traefik/34.1.0/defaults/crds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: traefik-crd-1.2.0-d2iq-defaults
namespace: ${releaseNamespace}
data:
values.yaml: |
# values.yaml content to enable only Gateway API CRDs installation
gatewayAPI: false
traefik: true
hub: false
deleteOnUninstall: false
3 changes: 2 additions & 1 deletion services/traefik/34.1.0/defaults/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- cm.yaml
- traefik.yaml
- crds.yaml
1 change: 1 addition & 0 deletions services/traefik/34.1.0/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ kind: Kustomization
resources:
- traefik.yaml
- grafana-dashboards
- crds.yaml
178 changes: 20 additions & 158 deletions services/traefik/34.1.0/traefik.yaml
Original file line number Diff line number Diff line change
@@ -1,161 +1,23 @@
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: traefik
name: traefik-helmrelease
namespace: ${releaseNamespace}
spec:
chart:
spec:
chart: traefik
sourceRef:
kind: HelmRepository
name: helm.traefik.io-traefik
namespace: kommander-flux
version: 34.1.0
interval: 15s
install:
crds: CreateReplace
remediation:
retries: 30
upgrade:
crds: CreateReplace
remediation:
retries: 30
timeout: 5m0s
releaseName: kommander-traefik
valuesFrom:
- kind: ConfigMap
name: traefik-34.1.0-d2iq-defaults
- kind: ConfigMap
name: traefik-overrides
optional: true
---
apiVersion: v1
kind: ConfigMap
metadata:
name: traefik-app-dashboard-info
namespace: ${releaseNamespace}
labels:
"kommander.d2iq.io/application": "traefik"
data:
name: "Traefik"
dashboardLink: "/dkp/traefik/dashboard/"
docsLink: "https://doc.traefik.io/traefik/v3.3"
# Check https://artifacthub.io/packages/helm/traefik/traefik for app version
version: "3.3.2"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: d2iq-traefik-certmanager-init
namespace: ${releaseNamespace}
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- '*'
- apiGroups:
- cert-manager.io
resources:
- certificates
verbs:
- '*'
- apiGroups:
- traefik.containo.us
- traefik.io
resources:
- tlsstores
- middlewares
verbs:
- '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: d2iq-traefik-certmanager-init
namespace: ${releaseNamespace}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: d2iq-traefik-certmanager-init
subjects:
- kind: ServiceAccount
name: kommander-traefik
namespace: ${releaseNamespace}
---
apiVersion: v1
kind: Service
metadata:
name: kommander-traefik-dashboard
namespace: ${releaseNamespace}
spec:
ports:
- name: dashboard-http
port: 80
protocol: TCP
targetPort: 9000
selector:
app: traefik
app.kubernetes.io/instance: kommander-traefik
type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
name: kommander-traefik-prometheus
namespace: ${releaseNamespace}
labels:
servicemonitor.kommander.mesosphere.io/path: metrics
spec:
ports:
- name: metrics
port: 9100
protocol: TCP
targetPort: metrics
selector:
app: traefik
app.kubernetes.io/instance: kommander-traefik
type: ClusterIP
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: dkp-traefik-view
rules:
- nonResourceURLs:
- /dkp/traefik
- /dkp/traefik/*
verbs:
- get
- head
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: dkp-traefik-edit
rules:
- nonResourceURLs:
- /dkp/traefik
- /dkp/traefik/*
verbs:
- get
- head
- post
- put
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: dkp-traefik-admin
rules:
- nonResourceURLs:
- /dkp/traefik
- /dkp/traefik/*
verbs:
- get
- head
- post
- put
- delete
force: false
prune: true
wait: true
interval: 6h
retryInterval: 1m
path: ./services/traefik/34.1.0/traefik
sourceRef:
kind: GitRepository
name: management
namespace: kommander-flux
timeout: 1m
postBuild:
substitute:
releaseNamespace: ${releaseNamespace}
substituteFrom:
- kind: ConfigMap
name: substitution-vars
4 changes: 4 additions & 0 deletions services/traefik/34.1.0/traefik/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- traefik.yaml
Loading
Loading