{%- set resourceName = kolla_kubernetes.cli.args.resource_name %}
{%- import "services/common/common-lib.yml.j2" as lib with context %}
apiVersion: v1
kind: ReplicationController
spec:
  replicas: {{ keystone_replicas }}
  selector:
      service: keystone
  template:
    metadata:
      labels:
        service: keystone
        type: api
      annotations:
        pod.beta.kubernetes.io/init-containers: '[
          {
             "name": "initialize-keystone-logs",
             "image": "{{ keystone_image_full }}",
             "imagePullPolicy": "IfNotPresent",
             "command": [
                 "sh",
                 "-ce",
                 "mkdir /var/log/kolla/keystone ;
                  chown -R keystone: /var/log/kolla/keystone;
                  chmod 755 /var/log/kolla/keystone; "],
             "volumeMounts": [
                {
                   "name": "kolla-logs",
                   "mountPath": "/var/log/kolla"
                }
             ]
          }
        ]'

    spec:
      nodeSelector:
{%- set selector = kolla_kubernetes_hostlabel_keystone |
                       default(kolla_kubernetes_hostlabel_controller)
%}
          {{ selector.key }}: {{ selector.value }}
      containers:
        - image: "{{ keystone_image_full }}"
          name: main
          volumeMounts:
{{ lib.common_volume_mounts(indent=12) }}
            - mountPath: {{ container_config_directory }}
              name: keystone-config
          env:
            - name: KOLLA_KUBERNETES
              value: ""
            - name: KOLLA_CONFIG_STRATEGY
              value: "{{ config_strategy }}"
          ports:
            - containerPort: {{ keystone_admin_port }}
              name: keystone-admin
            - containerPort: {{ keystone_public_port }}
              name: keystone-public
{{ lib.common_containers(indent=8) }}
      volumes:
{{ lib.common_volumes(indent=8) }}
        - name: keystone-config
          configMap:
            name: keystone
metadata:
   name: keystone
   namespace: {{ kolla_kubernetes_namespace }}
