# A headless service to create DNS records
apiVersion: v1
kind: Service
metadata:
  name: ub
  labels:
    app: ub
spec:
  ports:
  - port: 80
    name: web
  # *.ub.default.svc.cluster.local
  clusterIP: None
  selector:
    app: ub
---
apiVersion: apps/v1alpha1
kind: PetSet
metadata:
  name: vm
spec:
  serviceName: "ub"
  replicas: 2
  template:
    metadata:
      labels:
        app: ub
      annotations:
        pod.alpha.kubernetes.io/initialized: "true"
        pod.beta.kubernetes.io/init-containers: '[
            {
                "name": "rootfs",
                "image": "ubuntu:15.10",
                "command": [
                    "/bin/sh",
                    "-c",
                    "for d in usr lib etc; do cp -vnpr /$d/* /${d}mnt; done;"
                ],
                "volumeMounts": [
                    {
                        "name": "usr",
                        "mountPath": "/usrmnt"
                    },
                    {
                        "name": "lib",
                        "mountPath": "/libmnt"
                    },
                    {
                        "name": "etc",
                        "mountPath": "/etcmnt"
                    }
                ]
            }
        ]'
    spec:
      terminationGracePeriodSeconds: 0
      containers:
      - name: ub
        image: ubuntu:15.10
        ports:
        - containerPort: 80
          name: web
        command:
        - /bin/sh
        - -c
        - 'while true; do sleep 10; done'
        volumeMounts:
        - name: usr
          mountPath: /usr
        - name: lib
          mountPath: /lib
        - name: etc
          mountPath: /etc
  volumeClaimTemplates:
  - metadata:
      name: usr
      annotations:
        volume.alpha.kubernetes.io/storage-class: anything
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 300Mi
  - metadata:
      name: lib
      annotations:
        volume.alpha.kubernetes.io/storage-class: anything
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 1Gi
  - metadata:
      name: etc
      annotations:
        volume.alpha.kubernetes.io/storage-class: anything
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 150Mi

