---
kind: Template
apiVersion: v1
metadata:
  name: gluster-s3
  labels:
    glusterfs: s3-template
    gluster-s3: template
  annotations:
    description: Gluster S3 service template
    tags: glusterfs,heketi,gluster-s3
objects:
- kind: Service
  apiVersion: v1
  metadata:
    name: gluster-s3-${CLUSTER_NAME}-${S3_ACCOUNT}-service
    labels:
      glusterfs: s3-${CLUSTER_NAME}-${S3_ACCOUNT}-service
      gluster-s3: ${CLUSTER_NAME}-${S3_ACCOUNT}-service
  spec:
    ports:
    - protocol: TCP
      port: 8080
      targetPort: 8080
    selector:
      glusterfs: s3-${CLUSTER_NAME}-${S3_ACCOUNT}-pod
    type: ClusterIP
    sessionAffinity: None
  status:
    loadBalancer: {}
- kind: Route
  apiVersion: v1
  metadata:
    name: gluster-s3-${CLUSTER_NAME}-${S3_ACCOUNT}-route
    labels:
      glusterfs: s3-${CLUSTER_NAME}-${S3_ACCOUNT}-route
      gluster-s3: ${CLUSTER_NAME}-${S3_ACCOUNT}-route
  spec:
    to:
      kind: Service
      name: gluster-s3-${CLUSTER_NAME}-${S3_ACCOUNT}-service
- kind: DeploymentConfig
  apiVersion: v1
  metadata:
    name: gluster-s3-${CLUSTER_NAME}-${S3_ACCOUNT}-dc
    labels:
      glusterfs: s3-${CLUSTER_NAME}-${S3_ACCOUNT}-dc
      gluster-s3: ${CLUSTER_NAME}-${S3_ACCOUNT}-dc
    annotations:
      openshift.io/scc: privileged
      description: Defines how to deploy gluster s3 object storage
  spec:
    replicas: 1
    selector:
      glusterfs: s3-${CLUSTER_NAME}-${S3_ACCOUNT}-pod
    template:
      metadata:
        name: gluster-${CLUSTER_NAME}-${S3_ACCOUNT}-s3
        labels:
          glusterfs: s3-${CLUSTER_NAME}-${S3_ACCOUNT}-pod
          gluster-s3: ${CLUSTER_NAME}-${S3_ACCOUNT}-pod
      spec:
        containers:
        - name: gluster-s3
          image: ${IMAGE_NAME}
          imagePullPolicy: IfNotPresent
          ports:
          - name: gluster
            containerPort: 8080
            protocol: TCP
          env:
          - name: S3_ACCOUNT
            value: "${S3_ACCOUNT}"
          - name: S3_USER
            value: "${S3_USER}"
          - name: S3_PASSWORD
            value: "${S3_PASSWORD}"
          resources: {}
          volumeMounts:
          - name: gluster-vol1
            mountPath: "/mnt/gluster-object/${S3_ACCOUNT}"
          - name: gluster-vol2
            mountPath: "/mnt/gluster-object/gsmetadata"
          - name: glusterfs-cgroup
            readOnly: true
            mountPath: "/sys/fs/cgroup"
          terminationMessagePath: "/dev/termination-log"
          securityContext:
            privileged: true
        volumes:
        - name: glusterfs-cgroup
          hostPath:
            path: "/sys/fs/cgroup"
        - name: gluster-vol1
          persistentVolumeClaim:
            claimName: ${PVC}
        - name: gluster-vol2
          persistentVolumeClaim:
            claimName: ${META_PVC}
        restartPolicy: Always
        terminationGracePeriodSeconds: 30
        dnsPolicy: ClusterFirst
        serviceAccountName: default
        serviceAccount: default
        securityContext: {}
parameters:
- name: IMAGE_NAME
  displayName: glusterblock provisioner container image name
  required: True
- name: S3_ACCOUNT
  displayName: S3 Account Name
  description: S3 storage account which will provide storage on GlusterFS volumes
  required: true
- name: S3_USER
  displayName: S3 User
  description: S3 user who can access the S3 storage account
  required: true
- name: S3_PASSWORD
  displayName: S3 User Password
  description: Password for the S3 user
  required: true
- name: PVC
  displayName: Primary GlusterFS-backed PVC
  description: GlusterFS-backed PVC for object storage
  value: gluster-s3-claim
- name: META_PVC
  displayName: Metadata GlusterFS-backed PVC
  description: GlusterFS-backed PVC for object storage metadata
  value: gluster-s3-meta-claim
- name: CLUSTER_NAME
  displayName: GlusterFS cluster name
  description: A unique name to identify which heketi service manages this cluster, useful for running multiple heketi instances
  value: storage
