Home > Archives > Wordpress示例

Wordpress示例

Publish:

kubectl get nodes

# wordpress-secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: wordpress-secret
type: Opaque
data:
  db-password: cm9vdHBhc3M=

  
kubectl create -f wordpress-secret.yaml

# my-wordpress-deploy.yaml
apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: wordpress-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: wordpress-deployment
  template:
    metadata:
      labels:
        app: wordpress-deployment
    spec:
      containers:
      - name: wordpress
        image: wordpress:4-php7.0
        ports:
        - name: wordpress-port
          containerPort: 80
        env:
        - name: WORDPRESS_DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: wordpress-secret
              key: db-password
        - name: WORDPRESS_DB_HOST
          value: 127.0.0.1
      - name: mysql
        image: mysql:5.7
        ports:
        - name: mysql-port
          containerPort: 3306
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: wordpress-secret
              key: db-password

kubectl create -f my-wordpress-deploy.yaml
			  
# wordpress-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: wordpress-service
spec:
  ports:
  - port: 3000
    nodePort: 30300
	protocol: TCP
	targetPort: wordpress-port
  selector:
    app: wordpress-deployment
  type: NodePort

kubectl create -f wordpress-service.yaml
kubectl get all
kubectl get service

参考

声明: 本文采用 BY-NC-SA 授权。转载请注明转自: Ding Bao Guo