Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
2.1 kB
1
Indexable
Never
apiVersion: apps/v1
kind: Deployment
metadata:
  name: node-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: node-app
  template:
    metadata:
      labels:
        app: node-app
    spec:
      containers:
        - name: node-app
          image: fadhellya/test:1.0
          envFrom:
            - configMapRef:
                name: node-app-config
            - secretRef:
                name: passap
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: mysql-config
data:
  MYSQL_DATABASE: mydb
  MYSQL_ALLOW_EMPTY_PASSWORD: "no"
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: node-app-config
data:
  MYSQL_HOST: "mysql-service"
  MYSQL_USER: "root"
  MYSQL_DATABASE: "mydb"
  MYSQL_PORT: "3306"
---
apiVersion: v1
kind: Secret
metadata:
  name: mysql-pass
data:
  MYSQL_ROOT_PASSWORD: c2VjcmV0
---
apiVersion: v1
kind: Secret
metadata:
  name: passap
data:
  MYSQL_PASSWORD: c2VjcmV0
---
apiVersion: v1
kind: Pod
metadata:
  name: my-db
  labels:
    app: my-db
spec:
  containers:
    - name: my-db
      image: mysql:latest
      envFrom:
        - configMapRef:
            name: mysql-config
        - secretRef:
            name: mysql-pass
---
apiVersion: v1
kind: Service
metadata:
  name: node-app-service
spec:
  selector:
    app: node-app
  ports:
    - protocol: TCP
      port: 3000
      targetPort: 3000
  type: LoadBalancer
---
apiVersion: v1
kind: Service
metadata:
  name: mysql-service
spec:
  selector:
    app: my-db
  ports:
    - protocol: TCP
      port: 3306
      targetPort: 3306
---
apiVersion: v1
kind: Pod
metadata:
  name: my-phpmyadmin
  labels:
    app: my-phpmyadmin
spec:
  containers:
    - name: my-phpmyadmin
      image: phpmyadmin:latest
      env:
        - name: PMA_HOST
          value: mysql-service
      ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: my-phpmyadmin-service
spec:
  type: LoadBalancer
  selector:
    app: my-phpmyadmin
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 80
Leave a Comment