"Startup parameters" of openshift tips

When deploying applications on openshift, they are basically similar to docker, and can be hung on disk to add environment variables. Today, I record a relatively uncommon little knowledge.

When docker is deployed, container startup parameters are sometimes passed in, similar to:

docker run -p 9090:9090 \
         --restart=always \
         -d --name=prometheus \
         -v /data/prometheus/config/prometheus.yml:/etc/prometheus/prometheus.yml \
         -v /data/prometheus/prometheus_data_backup:/etc/prometheus/data \
         docker.io/prom/prometheus:v2.6.1 \
         --storage.tsdb.retention=365d \
         --web.enable-admin-api \
         --web.enable-lifecycle

After the image name, the root is the start parameter of the container, which is equivalent to:

/bin/bash /etc/prometheus/prometheus --storage.tsdb.retention=365d  --web.enable-admin-api --web.enable-lifecycle

There is no existing function in openshift. The value can modify the yaml file

  template:
    metadata:
      creationTimestamp: null
      labels:
        app: prometheus
        deploymentconfig: prometheus
    spec:
      containers:  # Add four lines above and below
        - args:
            - '--storage.tsdb.retention=365d'
            - '--web.enable-admin-api'
            - '--web.enable-lifecycle'
          image: >-
            docker.io/prom/prometheus@sha256:acd95556f589764b00bf0eb46048ab1cdedc95b4fa380c29e911f61dab7ecc51
          imagePullPolicy: IfNotPresent
          name: prometheus
          ports:
            - containerPort: 9090
              protocol: TCP
          resources:
            limits:
              cpu: 500m
              memory: 2Gi
            requests:
              cpu: 125m
              memory: 2Gi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File

Note: after args is added, the following columns, such as image, ports, resources, etc., should be backward one level. Otherwise, yaml format will report an error.

Let's check it after starting

/etc/prometheus $ ps -ef
PID   USER     TIME  COMMAND
    1 nobody    0:03 /bin/prometheus --storage.tsdb.retention=365d --web.enable-admin-api --web.enable-lifecycle
   29 nobody    0:00 /bin/sh
   75 nobody    0:00 /bin/sh
   92 nobody    0:00 /bin/sh
   99 nobody    0:00 ps -ef

Tags: Operation & Maintenance Docker

Posted on Tue, 21 Apr 2020 08:13:25 -0700 by tigger