mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 10:15:22 +00:00
Add wordpress example for demonstrating variable reference
This commit is contained in:
19
examples/wordpress/kustomization.yaml
Normal file
19
examples/wordpress/kustomization.yaml
Normal file
@@ -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
|
||||
|
||||
35
examples/wordpress/mysql/deployment.yaml
Normal file
35
examples/wordpress/mysql/deployment.yaml
Normal file
@@ -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: {}
|
||||
4
examples/wordpress/mysql/kustomization.yaml
Normal file
4
examples/wordpress/mysql/kustomization.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
- secret.yaml
|
||||
8
examples/wordpress/mysql/secret.yaml
Normal file
8
examples/wordpress/mysql/secret.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: mysql-pass
|
||||
type: Opaque
|
||||
data:
|
||||
# Default password is "admin".
|
||||
password: YWRtaW4=
|
||||
11
examples/wordpress/mysql/service.yaml
Normal file
11
examples/wordpress/mysql/service.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mysql
|
||||
labels:
|
||||
app: mysql
|
||||
spec:
|
||||
ports:
|
||||
- port: 3306
|
||||
selector:
|
||||
app: mysql
|
||||
23
examples/wordpress/patch.yaml
Normal file
23
examples/wordpress/patch.yaml
Normal file
@@ -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
|
||||
29
examples/wordpress/wordpress/deployment.yaml
Normal file
29
examples/wordpress/wordpress/deployment.yaml
Normal file
@@ -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: {}
|
||||
3
examples/wordpress/wordpress/kustomization.yaml
Normal file
3
examples/wordpress/wordpress/kustomization.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
12
examples/wordpress/wordpress/service.yaml
Normal file
12
examples/wordpress/wordpress/service.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: wordpress
|
||||
labels:
|
||||
app: wordpress
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
selector:
|
||||
app: wordpress
|
||||
type: LoadBalancer
|
||||
@@ -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"},
|
||||
|
||||
Reference in New Issue
Block a user