From 93abe6bed0a5f03ccf034188a4a09e07201347f2 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Wed, 26 Feb 2025 09:10:10 +0100 Subject: [PATCH] Add namespace oka and update jenkins and testacme okas to follow best practices Signed-off-by: garciadeblas --- oka/apps/jenkins-ns-params.yaml | 1 + oka/apps/jenkins/manifests/jenkins-hr.yaml | 2 - oka/apps/jenkins/templates/jenkins-ks.yaml | 27 ++++++++++++- oka/apps/namespace/manifests/namespace.yaml | 23 +++++++++++ .../namespace/templates/namespace-ks.yaml | 40 +++++++++++++++++++ ...estacmeappco.yaml => testacme-deploy.yaml} | 19 --------- .../manifests/testacme-ns.yaml} | 4 +- oka/apps/testacme/manifests/testacme-svc.yaml | 18 +++++++++ oka/apps/testacme/templates/testacme-ks.yaml | 5 --- 9 files changed, 110 insertions(+), 29 deletions(-) create mode 100644 oka/apps/jenkins-ns-params.yaml create mode 100644 oka/apps/namespace/manifests/namespace.yaml create mode 100644 oka/apps/namespace/templates/namespace-ks.yaml rename oka/apps/testacme/manifests/{testacmeappco.yaml => testacme-deploy.yaml} (72%) rename oka/apps/{jenkins/templates/jenkins-ns.yaml => testacme/manifests/testacme-ns.yaml} (97%) create mode 100644 oka/apps/testacme/manifests/testacme-svc.yaml diff --git a/oka/apps/jenkins-ns-params.yaml b/oka/apps/jenkins-ns-params.yaml new file mode 100644 index 00000000..c9a14f79 --- /dev/null +++ b/oka/apps/jenkins-ns-params.yaml @@ -0,0 +1 @@ +namespace: jenkins diff --git a/oka/apps/jenkins/manifests/jenkins-hr.yaml b/oka/apps/jenkins/manifests/jenkins-hr.yaml index fd4108e4..f83ae764 100644 --- a/oka/apps/jenkins/manifests/jenkins-hr.yaml +++ b/oka/apps/jenkins/manifests/jenkins-hr.yaml @@ -30,8 +30,6 @@ spec: kind: HelmRepository name: bitnamicharts namespace: jenkins - install: - createNamespace: true interval: 3m0s targetNamespace: jenkins values: {} diff --git a/oka/apps/jenkins/templates/jenkins-ks.yaml b/oka/apps/jenkins/templates/jenkins-ks.yaml index 62bc3003..616304b8 100644 --- a/oka/apps/jenkins/templates/jenkins-ks.yaml +++ b/oka/apps/jenkins/templates/jenkins-ks.yaml @@ -18,14 +18,39 @@ apiVersion: kustomize.toolkit.fluxcd.io/v1 kind: Kustomization metadata: - name: jenkins + name: ${APPNAME} namespace: flux-system spec: interval: 1h0m0s path: ./apps/jenkins/manifests prune: true + targetNamespace: ${TARGET_NS} wait: true sourceRef: kind: GitRepository name: sw-catalogs namespace: flux-system + patches: + # - target: + # kind: Namespace + # version: v1 + # name: jenkins + # patch: |- + # kind: Namespace + # metadata: + # name: ${TARGET_NS} + - target: + kind: HelmRelease + version: v2beta1 + name: jenkins + namespace: jenkins + patch: |- + - op: replace + path: /metadata/name + value: ${APPNAME} + - op: replace + path: /spec/chart/spec/sourceRef/namespace + value: ${TARGET_NS} + - op: replace + path: /spec/targetNamespace + value: ${TARGET_NS} diff --git a/oka/apps/namespace/manifests/namespace.yaml b/oka/apps/namespace/manifests/namespace.yaml new file mode 100644 index 00000000..ac2c4afb --- /dev/null +++ b/oka/apps/namespace/manifests/namespace.yaml @@ -0,0 +1,23 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +apiVersion: v1 +kind: Namespace +metadata: + name: mynamespace + annotations: + kustomize.toolkit.fluxcd.io/ssa: "IfNotPresent" diff --git a/oka/apps/namespace/templates/namespace-ks.yaml b/oka/apps/namespace/templates/namespace-ks.yaml new file mode 100644 index 00000000..3e22d968 --- /dev/null +++ b/oka/apps/namespace/templates/namespace-ks.yaml @@ -0,0 +1,40 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: ${APPNAME} + namespace: flux-system +spec: + interval: 1h0m0s + path: ./apps/namespace/manifests + prune: true + # deletionPolicy: Orphan + sourceRef: + kind: GitRepository + name: sw-catalogs + namespace: flux-system + patches: + - target: + kind: Namespace + version: v1 + name: mynamespace + patch: |- + - op: replace + path: /metadata/name + value: ${TARGET_NS} diff --git a/oka/apps/testacme/manifests/testacmeappco.yaml b/oka/apps/testacme/manifests/testacme-deploy.yaml similarity index 72% rename from oka/apps/testacme/manifests/testacmeappco.yaml rename to oka/apps/testacme/manifests/testacme-deploy.yaml index 65404e7a..1138a8d1 100644 --- a/oka/apps/testacme/manifests/testacmeappco.yaml +++ b/oka/apps/testacme/manifests/testacme-deploy.yaml @@ -1,22 +1,3 @@ -apiVersion: v1 -kind: Service -metadata: - creationTimestamp: null - labels: - config: ${appname} - run: ${appname} - name: ${appname}-http - namespace: ${target_ns} -spec: - ports: - - name: http5678tls - port: 5678 - protocol: TCP - targetPort: 5678 - selector: - run: ${appname} - type: ClusterIP ---- apiVersion: apps/v1 kind: Deployment metadata: diff --git a/oka/apps/jenkins/templates/jenkins-ns.yaml b/oka/apps/testacme/manifests/testacme-ns.yaml similarity index 97% rename from oka/apps/jenkins/templates/jenkins-ns.yaml rename to oka/apps/testacme/manifests/testacme-ns.yaml index 4143ffe1..80c8fb09 100644 --- a/oka/apps/jenkins/templates/jenkins-ns.yaml +++ b/oka/apps/testacme/manifests/testacme-ns.yaml @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. ####################################################################################### ---- + apiVersion: v1 kind: Namespace metadata: - name: jenkins + name: ${target_ns} diff --git a/oka/apps/testacme/manifests/testacme-svc.yaml b/oka/apps/testacme/manifests/testacme-svc.yaml new file mode 100644 index 00000000..fa4224ef --- /dev/null +++ b/oka/apps/testacme/manifests/testacme-svc.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + creationTimestamp: null + labels: + config: ${appname} + run: ${appname} + name: ${appname}-http + namespace: ${target_ns} +spec: + ports: + - name: http5678tls + port: 5678 + protocol: TCP + targetPort: 5678 + selector: + run: ${appname} + type: ClusterIP diff --git a/oka/apps/testacme/templates/testacme-ks.yaml b/oka/apps/testacme/templates/testacme-ks.yaml index 3a21e701..38df03fa 100644 --- a/oka/apps/testacme/templates/testacme-ks.yaml +++ b/oka/apps/testacme/templates/testacme-ks.yaml @@ -1,8 +1,3 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: ${TARGET_NS} ---- apiVersion: kustomize.toolkit.fluxcd.io/v1 kind: Kustomization metadata: -- GitLab