apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: openslice
  labels:
    org.etsi.osl.service: osscapi
  name: osscapi
spec:
  replicas: 1
  selector:
    matchLabels:
      org.etsi.osl.service: osscapi
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        org.etsi.osl.service: osscapi
    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&useSSL=false&requireSSL=false&useUnicode=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",
                  "spring.security.oauth2.resourceserver.jwt.jwk-set-uri":"http://INGRESSADDR/auth/realms/openslice/.well-known/openid-configuration",
                  "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",
                  "kroki.serverurl":"http://INGRESSADDR/kroki"
                }
          image: labs.etsi.org:5050/osl/code/org.etsi.osl.tmf.api:develop
          name: openslice-scapi
          ports:
            - containerPort: 13082
          volumeMounts:
            - mountPath: /root
              name: osscapi-claim0
          readinessProbe:
            httpGet:
              path: /tmf-api/serviceCatalogManagement/v4/serviceCatalog
              port: 13082
      restartPolicy: Always
      volumes:
        - name: osscapi-claim0
          persistentVolumeClaim:
            claimName: osscapi-claim0
---
apiVersion: v1
kind: Service
metadata:
  namespace: openslice
  labels:
    org.etsi.osl.service: osscapi
  name: osscapi
spec:
  ports:
    - name: "13082"
      targetPort: 13082
      port: 13082
  selector:
    org.etsi.osl.service: osscapi
