Skip to content

Commit

Permalink
use apply-replacement to update configMapKeyRef namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwenma committed Jul 21, 2022
1 parent ed4b59d commit 455b032
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 40 deletions.
2 changes: 2 additions & 0 deletions package-examples/ghost/Kptfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ pipeline:
configPath: setlabels.yaml
- image: gcr.io/kpt-fn/set-namespace:v0.3.4
configPath: package-context.yaml
- image: gcr.io/kpt-fn/apply-replacements:v0.1.1
configPath: applyreplacements.yaml
20 changes: 20 additions & 0 deletions package-examples/ghost/applyreplacements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: fn.kpt.dev/v1alpha1
kind: ApplyReplacements
metadata:
name: replacements-cm-namespace
annotations:
config.kubernetes.io/local-config: "true"
replacements:
- source:
kind: ConfigMap
name: kptfile.kpt.dev
fieldPath: data.name # the `set-namespace` fn-config
targets:
- select:
kind: Deployment
fieldPaths:
- spec.template.spec.containers.[name=ghost-app].envFrom.[=].configMapRef.namespace
- select:
kind: StatefulSet
fieldPaths:
- spec.template.spec.containers.[name=ghost-app].envFrom.[=].configMapRef.namespace
22 changes: 22 additions & 0 deletions package-examples/ghost/configmap-env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Source: ghost/charts/mariadb/templates/primary/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: ghost-env
namespace: example
data:
BITNAMI_DEBUG: "true"
ALLOW_EMPTY_PASSWORD: "yes"
GHOST_DATABASE_HOST: "mariadb"
GHOST_DATABASE_PORT_NUMBER: "3306"
GHOST_DATABASE_NAME: "bitnami_ghost"
GHOST_DATABASE_USER: "bn_ghost"
GHOST_HOST: EXTERNAL_IP_FROM_SERVICE
GHOST_PORT_NUMBER: "2368"
GHOST_USERNAME: "user"
GHOST_EMAIL: "user@example.com"
GHOST_BLOG_TITLE: "User's Blog"
GHOST_ENABLE_HTTPS: "no"
GHOST_EXTERNAL_HTTP_PORT_NUMBER: "80"
GHOST_EXTERNAL_HTTPS_PORT_NUMBER: "443"
GHOST_SKIP_BOOTSTRAP: "no"
35 changes: 4 additions & 31 deletions package-examples/ghost/deployment-ghost.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,10 @@ spec:
securityContext:
runAsNonRoot: true
runAsUser: 1001
env:
- name: BITNAMI_DEBUG
value: "true"
- name: ALLOW_EMPTY_PASSWORD
value: "yes"
- name: GHOST_DATABASE_HOST
value: "mariadb"
- name: GHOST_DATABASE_PORT_NUMBER
value: "3306"
- name: GHOST_DATABASE_NAME
value: "bitnami_ghost"
- name: GHOST_DATABASE_USER
value: "bn_ghost"
- name: GHOST_HOST
value: EXTERNAL_IP_FROM_SERVICE
- name: GHOST_PORT_NUMBER
value: "2368"
- name: GHOST_USERNAME
value: "user"
- name: GHOST_EMAIL
value: "user@example.com"
- name: GHOST_BLOG_TITLE
value: "User's Blog"
- name: GHOST_ENABLE_HTTPS
value: "no"
- name: GHOST_EXTERNAL_HTTP_PORT_NUMBER
value: "80"
- name: GHOST_EXTERNAL_HTTPS_PORT_NUMBER
value: "443"
- name: GHOST_SKIP_BOOTSTRAP
value: "no"
envFrom:
- configMapRef:
name: ghost-env
namespace: example
ports:
- name: http
containerPort: 2368
Expand Down
13 changes: 4 additions & 9 deletions package-examples/ghost/statefulset-mariadb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ spec:
securityContext:
runAsNonRoot: true
runAsUser: 1001
env:
- name: BITNAMI_DEBUG
value: "true"
- name: MARIADB_USER
value: "bn_ghost"
- name: MARIADB_DATABASE
value: "bitnami_ghost"
- name: ALLOW_EMPTY_PASSWORD
value: "true"
envFrom:
- configMapRef:
name: ghost-env
namespace: example
ports:
- name: mysql
containerPort: 3306
Expand Down

0 comments on commit 455b032

Please sign in to comment.