1

I have this StartupProbe:

      startupProbe:
        httpGet:
          path: someurl
          port: 6060
          scheme: HTTP
        periodSeconds: 10
        successThreshold: 1
        failureThreshold: 12
        timeoutSeconds: 9

When trying to apply that probe in a DeploymentConfig like this:

 (oc process -f path/to/DeploymentConfig.yml \
        -p SomeVariable=$SomeVariable \
        | oc apply -f - \
 )

It runs into this Error:

error: unable to find api field in struct Container for the json field "startupProbe"

Note the following things:

  • The DeploymentConfig worked before. I only added the Startupprobe.
  • The First Deployment is successful but the second and following are not due to the mentioned Error
  • When editing/adding/rollouting the DeploymentConfig in Openshift directly, then there is no issue => the startupProbe should be valid
  • I don't have access to Openshift Logs only the Events. The Events contain no Errors.
  • The Deployment and Error happen inside a Gitlab pipeline. In other words: Openshift blocks the Config before applying it.
  • the Openshift Plattform Version should be the 4.12

Question(s)

  • How/Why is this Error exactly triggered?
  • How can I prevent the Error?

Edit (Adding DeploymentConfig)

apiVersion: v1
kind: Template
metadata:
  name: deploymentconfig-template
objects:
  - apiVersion: apps.openshift.io/v1
    kind: DeploymentConfig
    metadata:
      labels:
        app: ${IMAGE_NAME}-${TARGET_SYSTEM}
      name: ${IMAGE_NAME}-${TARGET_SYSTEM}
      namespace: ${OPENSHIFT_NAMESPACE}
    spec:
      replicas: 1
      revisionHistoryLimit: 10
      selector:
        app: ${IMAGE_NAME}-${TARGET_SYSTEM}
        deploymentconfig: ${IMAGE_NAME}-${TARGET_SYSTEM}
      strategy:
        activeDeadlineSeconds: 21600
        resources: {}
        rollingParams:
          intervalSeconds: 1
          maxSurge: 25%
          maxUnavailable: 25%
          timeoutSeconds: 600
          updatePeriodSeconds: 1
        type: Rolling
      template:
        metadata:
          labels:
            app: ${IMAGE_NAME}-${TARGET_SYSTEM}
            deploymentconfig: ${IMAGE_NAME}-${TARGET_SYSTEM}
        spec:
          containers:
            - name: ${IMAGE_NAME}
              image: ${DOCKER_REGISTRY}/${DOCKER_NAMESPACE}/${IMAGE_NAME}:${IMAGE_TAG}
              imagePullPolicy: Always
              ports:
                - containerPort: 5555
                  protocol: TCP
              resources:
                requests:
                  memory: 120Mi
                limits:
                  memory: 200Mi
              livenessProbe:
                exec:
                  command:
                    - /bin/sh
                    - -c
                    - nc -z localhost 5555
                initialDelaySeconds: 60
                periodSeconds: 10
              readinessProbe:
                httpGet:
                  path: someurl
                  port: 6060
                  scheme: HTTP
                initialDelaySeconds: 30
                periodSeconds: 60
                successThreshold: 1
                failureThreshold: 3
                timeoutSeconds: 60
              startupProbe:
                httpGet:
                  path: someurl
                  port: 6060
                  scheme: HTTP
                periodSeconds: 20
                successThreshold: 1
                failureThreshold: 20
                timeoutSeconds: 19
              terminationMessagePath: /dev/termination-log
              terminationMessagePolicy: File
              env:
                - name: SERVICE_ACCOUNT_ENABLED
                  value: ${SERVICE_ACCOUNT_ENABLED}
                - name: NODE_TLS_REJECT_UNAUTHORIZED
                  value: "0"
              envFrom:
                - configMapRef:
                    name: ${IMAGE_NAME}-${TARGET_SYSTEM}
              volumeMounts:
                - name: keycloak-json-server
                  mountPath: /server/keycloak/keycloak.json
                  subPath: keycloak.json
                - name: keycloak-2fa-disabled-json-server
                  mountPath: /server/keycloak/keycloak_2FAdisabled.json
                  subPath: keycloak_2FAdisabled.json
                - mountPath: /server/modules/external_apis/eko-ora/deploy-config
                  name: deploy-config
                - mountPath: /server/deploy-config
                  name: deploy-global-config
          imagePullSecrets:
            - name: mtr
          dnsPolicy: ClusterFirst
          restartPolicy: Always
          schedulerName: default-scheduler
          securityContext: {}
          terminationGracePeriodSeconds: 30
          volumes:
            - name: keycloak-json-server
              configMap:
                name: ${IMAGE_NAME}-${TARGET_SYSTEM}
                items:
                  - key: keycloak.json
                    path: keycloak.json
            - name: keycloak-2fa-disabled-json-server
              configMap:
                name: ${IMAGE_NAME}-${TARGET_SYSTEM}
                items:
                  - key: keycloak_2FAdisabled.json
                    path: keycloak_2FAdisabled.json
            - name: deploy-config
              configMap:
                name: ${IMAGE_NAME}-${TARGET_SYSTEM}
                items:
                  - key: eko-ora.deploy.json
                    path: eko-ora.deploy.json
                  - key: scim.deploy.json
                    path: scim.deploy.json
                  - key: apiSettings.deploy.json
                    path: apiSettings.deploy.json
            - name: deploy-global-config
              configMap:
                name: ${IMAGE_NAME}-${TARGET_SYSTEM}
                items:
                  - key: globalSettings.deploy.json
                    path: globalSettings.deploy.json
                  - key: roleBasedUI.deploy.json
                    path: roleBasedUI.deploy.json
                  - key: createUserReq.deploy.json
                    path: createUserReq.deploy.json
                  - key: searchUserReq.deploy.json
                    path: searchUserReq.deploy.json
      test: false
parameters:
  - name: TARGET_SYSTEM
  - name: OPENSHIFT_NAMESPACE
  - name: DOCKER_REGISTRY
  - name: DOCKER_NAMESPACE
  - name: IMAGE_NAME
  - name: IMAGE_TAG
  - name: SERVICE_ACCOUNT_ENABLED
telion
  • 834
  • 1
  • 9
  • 34
  • Can you post the whole yaml? this is most commonly an indendation issue – Rick Rackow Aug 08 '23 at 11:36
  • I can't share company code that easily. I have ruled that out due to: 1. It works if the startupProbe did not exist before and is added. 2. It works when adding it to the DeploymentConfig in the OpenshiftUI. 3. Having yml lints in Place. 4. Reading the examples of the Docs 5. Having Readyness and Livenessprobes at the same location that have no Issue. – telion Aug 08 '23 at 12:49
  • I asked my superiors and they allowed me to added the File, after some anonymization. I am add the file soon. – telion Aug 08 '23 at 13:30

1 Answers1

0

So after some testing and research, this was the problem/solution:

The oc command was executed in a GitLab job. This job used a docker Image to execute the various commands including the oc one.

The Image however was out of date or rather the openshift CLI in it. After updating the Image everything worked as expected.

telion
  • 834
  • 1
  • 9
  • 34