Openshift 3.11 - edit deployment config - cant add command

6/28/2019

I'm attempting to edit the yaml of a deployment config in the OpenShift web console.

I'm simply trying to add a command and some args. I have another working example with the correct syntax and indentation.

However, when I copy this into the deployment config, Im unable to save it due to a validation error. However the error doesnt relate to the change I've made.

The error message is:

Failed to process the resource. Reason: DeploymentConfig.apps.openshift.io "my-sdk" is invalid: [spec.template.spec.containers[0].name: Required value, spec.template.spec.containers[0].image: Required value]

For example, I have the following snippet from the working deployment config:

    spec:
      containers:
        - env:
            - name: MY_DB_HOST
              value: postgresql
            - name: MY_DB_NAME
              value: MY
            - name: MY_DB_PASSWORD
              value: MY
            - name: MY_DB_USER
              value: MY
            - name: MY_CACHE_ENABLED
              value: 'false'
          image: >-
            172.30.1.1:5000/myapp/my-sdk@sha256:eb485f011eaab9342b7fcf272c9f22dded9c238987f1dec932f8e1640ac18251
          imagePullPolicy: Always
          name: my-sdk
          ports:
            - containerPort: 8080
              protocol: TCP

Then I attempt to change it to the following:

    spec:
      containers:
        - args:
            - '-myarg'
          command:
            - node
        - env:
            - name: MY_DB_HOST
              value: postgresql
            - name: MY_DB_NAME
              value: MY
            - name: MY_DB_PASSWORD
              value: MY
            - name: MY_DB_USER
              value: MY
            - name: MY_CACHE_ENABLED
              value: 'false'
          image: >-
            172.30.1.1:5000/myapp/my-sdk@sha256:eb485f011eaab9342b7fcf272c9f22dded9c238987f1dec932f8e1640ac18251
          imagePullPolicy: Always
          name: my-sdk
          ports:
            - containerPort: 8080
              protocol: TCP

And with this change I get the above error. I'm 99% certain the change I made is valid, as I'm simply coping it from a functional deployment config. And the error message doesnt seem to relate at all to the change.

Update

Now I have a working deploymentconfig that contains command and arg values.

When I try to remove these, without modifying any other yaml, or indentation, I get the following useless validation error:

Failed to process the resource. Reason: ReplicationController in version "v1" cannot be handled as a ReplicationController: v1.ReplicationController.Spec: v1.ReplicationControllerSpec.Template: v1.PodTemplateSpec.Spec: v1.PodSpec.TerminationGracePeriodSeconds: SecurityContext: SchedulerName: RestartPolicy: DNSPolicy: Containers: decode slice: expect [ or n, but found {, error found in #10 byte of ...|y":"File"},"dnsPolic|..., bigger context ...|ermination-log","terminationMessagePolicy":"File"},"dnsPolicy":"ClusterFirst","restartPolicy":"Alway|...

-- Magick
kubernetes
openshift

1 Answer

6/28/2019

One example:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx@sha256:e3456c851a152494c3e4ff5fcc26f240206abac0c9d794affb40e0714846c451
        env:
         - name: DEMO_GREETING
           value: "Hello from the environment"
        command: ["echo"]
        args: ["$(GREETING) $(HONORIFIC) $(NAME)"] 
        ports:
        - containerPort: 80

Please follow documentation: Using environment variables inside of your config

In addition please verify your spec with the image line image: >- as per error image: Required value

-- Hanx
Source: StackOverflow