diff --git a/examples/wordpress/kustomization.yaml b/examples/wordpress/kustomization.yaml new file mode 100644 index 000000000..c9d7c8dcd --- /dev/null +++ b/examples/wordpress/kustomization.yaml @@ -0,0 +1,19 @@ +bases: + - wordpress + - mysql +patches: + - patch.yaml +namePrefix: demo- + +vars: + - name: WORDPRESS_SERVICE + objref: + kind: Service + name: wordpress + apiVersion: v1 + - name: MYSQL_SERVICE + objref: + kind: Service + name: mysql + apiVersion: v1 + diff --git a/examples/wordpress/mysql/deployment.yaml b/examples/wordpress/mysql/deployment.yaml new file mode 100644 index 000000000..6aa7bc72b --- /dev/null +++ b/examples/wordpress/mysql/deployment.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1beta2 # for versions before 1.9.0 use apps/v1beta2 +kind: Deployment +metadata: + name: mysql + labels: + app: mysql +spec: + selector: + matchLabels: + app: mysql + strategy: + type: Recreate + template: + metadata: + labels: + app: mysql + spec: + containers: + - image: mysql:5.6 + name: mysql + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-pass + key: password + ports: + - containerPort: 3306 + name: mysql + volumeMounts: + - name: mysql-persistent-storage + mountPath: /var/lib/mysql + volumes: + - name: mysql-persistent-storage + emptyDir: {} diff --git a/examples/wordpress/mysql/kustomization.yaml b/examples/wordpress/mysql/kustomization.yaml new file mode 100644 index 000000000..bc664d1b1 --- /dev/null +++ b/examples/wordpress/mysql/kustomization.yaml @@ -0,0 +1,4 @@ +resources: +- deployment.yaml +- service.yaml +- secret.yaml diff --git a/examples/wordpress/mysql/secret.yaml b/examples/wordpress/mysql/secret.yaml new file mode 100644 index 000000000..cd9335fc0 --- /dev/null +++ b/examples/wordpress/mysql/secret.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: mysql-pass +type: Opaque +data: + # Default password is "admin". + password: YWRtaW4= diff --git a/examples/wordpress/mysql/service.yaml b/examples/wordpress/mysql/service.yaml new file mode 100644 index 000000000..aa3f970b6 --- /dev/null +++ b/examples/wordpress/mysql/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: mysql + labels: + app: mysql +spec: + ports: + - port: 3306 + selector: + app: mysql diff --git a/examples/wordpress/patch.yaml b/examples/wordpress/patch.yaml new file mode 100644 index 000000000..f7a57f4d2 --- /dev/null +++ b/examples/wordpress/patch.yaml @@ -0,0 +1,23 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: wordpress +spec: + template: + spec: + initContainers: + - name: init-command + image: debian + command: + - "echo $(WORDPRESS_SERVICE)" + - "echo $(MYSQL_SERVICE)" + containers: + - name: wordpress + env: + - name: WORDPRESS_DB_HOST + value: mysql + - name: WORDPRESS_DB_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-pass + key: password diff --git a/examples/wordpress/wordpress/deployment.yaml b/examples/wordpress/wordpress/deployment.yaml new file mode 100644 index 000000000..07e055239 --- /dev/null +++ b/examples/wordpress/wordpress/deployment.yaml @@ -0,0 +1,29 @@ +apiVersion: apps/v1beta2 # for versions before 1.9.0 use apps/v1beta2 +kind: Deployment +metadata: + name: wordpress + labels: + app: wordpress +spec: + selector: + matchLabels: + app: wordpress + strategy: + type: Recreate + template: + metadata: + labels: + app: wordpress + spec: + containers: + - image: wordpress:4.8-apache + name: wordpress + ports: + - containerPort: 80 + name: wordpress + volumeMounts: + - name: wordpress-persistent-storage + mountPath: /var/www/html + volumes: + - name: wordpress-persistent-storage + emptyDir: {} diff --git a/examples/wordpress/wordpress/kustomization.yaml b/examples/wordpress/wordpress/kustomization.yaml new file mode 100644 index 000000000..a944d005c --- /dev/null +++ b/examples/wordpress/wordpress/kustomization.yaml @@ -0,0 +1,3 @@ +resources: +- deployment.yaml +- service.yaml diff --git a/examples/wordpress/wordpress/service.yaml b/examples/wordpress/wordpress/service.yaml new file mode 100644 index 000000000..6be89be13 --- /dev/null +++ b/examples/wordpress/wordpress/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: wordpress + labels: + app: wordpress +spec: + ports: + - port: 80 + selector: + app: wordpress + type: LoadBalancer diff --git a/pkg/transformers/refvars.go b/pkg/transformers/refvars.go index 1be055e95..7d25a245b 100644 --- a/pkg/transformers/refvars.go +++ b/pkg/transformers/refvars.go @@ -26,6 +26,14 @@ func NewRefVarTransformer(vars map[string]string) (Transformer, error) { GroupVersionKind: &schema.GroupVersionKind{Kind: "StatefulSet"}, Path: []string{"spec", "template", "spec", "containers", "command"}, }, + { + GroupVersionKind: &schema.GroupVersionKind{Kind: "Deployment"}, + Path: []string{"spec", "template", "spec", "initContainers", "command"}, + }, + { + GroupVersionKind: &schema.GroupVersionKind{Kind: "Deployment"}, + Path: []string{"spec", "template", "spec", "containers", "command"}, + }, { GroupVersionKind: &schema.GroupVersionKind{Kind: "Job"}, Path: []string{"spec", "template", "spec", "containers", "command"},