apiVersion: v1
kind: Namespace
metadata:
  name: green-project
  labels:
    app: green

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: green
  labels:
    app: green
  namespace: green-project
spec:
  replicas: 2
  selector:
    matchLabels:
      app: green
  template:
    metadata:
      labels:
        app: green
    spec:
      volumes:
      - name: websitedata
        emptyDir: {}
      initContainers:
      - name: webcontent
        image: busybox
        volumeMounts:
        - name: websitedata
          mountPath: /websitedata
        command: ["/bin/sh"]
        args: ["-c", 'echo "<h1>Welcome to <font color=green> http://vcloud-lab.com Green_Application</font></h1>" > /websitedata/index.html']
      containers:
      - name: green
        image: nginx
        ports:
        - containerPort: 80
        volumeMounts:
        - name: websitedata
          mountPath: "/usr/share/nginx/html" #For nginx image path - "/usr/share/nginx/html"
          readOnly: true

---

apiVersion: v1
kind: Service
metadata:
  name: green-svc
  namespace: green-project
spec:
  selector:
    app: green
  type: LoadBalancer
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
