apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: openslice
  labels:
    org.etsi.osl.service: oasapi
  name: oasapi
spec:
  replicas: 1
  selector:
    matchLabels:
      org.etsi.osl.service: oasapi
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        org.etsi.osl.service: oasapi
    spec:
      initContainers:
      - name: init-keycloak
        image: busybox:1.28
        command: ['sh', '-c', "until nslookup keycloak; do echo waiting for keycloak; sleep 2; done"]
      - name: init-mysql-portal
        image: busybox:1.28
        command: ['sh', '-c', "until nslookup mysql; do echo waiting for mysql; sleep 2; done"]
      containers:
        - env:
            - name: SPRING_APPLICATION_JSON
              value: >-
                { 
                  "spring.datasource.url": "jdbc:mysql://mysql/ostmfdb?createDatabaseIfNotExist=true&useUnicode=true&nullCatalogMeansCurrent=true&characterEncoding=utf8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC", 
                  "spring.datasource.username":"root", 
                  "spring.datasource.password":"letmein", 
                  "spring-addons.issuers[0].uri": "http://INGRESSADDR/auth/realms/openslice", 
                  "spring-addons.issuers[0].username-json-path":"$.preferred_username", 
                  "spring-addons.issuers[0].claims[0].jsonPath":"$.realm_access.roles", 
                  "spring-addons.issuers[0].claims[1].jsonPath":"$.resource_access.*.roles", 
                  "spring.security.oauth2.resourceserver.jwt.issuer-uri": "http://INGRESSADDR/auth/realms/openslice", 
                  "springdoc.oAuthFlow.authorizationUrl": "http://INGRESSADDR/auth/realms/openslice/protocol/openid-connect/auth", 
                  "springdoc.oAuthFlow.tokenUrl": "http://INGRESSADDR/auth/realms/openslice/protocol/openid-connect/token", 
                  "springdoc.oauth.client-id" : "osapiWebClientId", 
                  "springdoc.oauth.clientsecret" : "secret", 
                  "spring.activemq.brokerUrl": "tcp://artemis:61616?jms.watchTopicAdvisories=false", 
                  "spring.activemq.user": "artemis", 
                  "spring.activemq.password": "artemis", 
                  "logging.level.org.springframework" : "INFO" 
                }
          image: openslice/org.etsi.osl.oas:latest
          name: openslice-oasapi
          ports:
            - containerPort: 13101
          volumeMounts:
            - mountPath: /root
              name: oasapi-claim0
          readinessProbe:
            httpGet:
              path: /oas-api/swagger-ui/index.html
              port: 13101
      restartPolicy: Always
      volumes:
        - name: oasapi-claim0
          persistentVolumeClaim:
            claimName: oasapi-claim0
---
apiVersion: v1
kind: Service
metadata:
  namespace: openslice
  labels:
    org.etsi.osl.service: oasapi
  name: oasapi
spec:
  ports:
    - name: "13101"
      targetPort: 13101
      port: 13101
  selector:
    org.etsi.osl.service: oasapi
