How I can upgrade an new version of container in Openshift/Kubernetes

1/9/2018

I have an openshift cluster. Docker images I store in a gitlab registry And I have a question, when I have a new image on my repo, how can I upgrade an my application in openshift?

for example I have a deployed selenium hub with version 3.6 :

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert -f docker-compose-debug.yml
    kompose.version: 1.6.0 (e4adfef)
  creationTimestamp: null
  labels:
    io.kompose.service: ds-hub
  name: ds-hub
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: ds-hub
    spec:
      containers:
      - env:
        - name: GRID_CLEAN_UP_CYCLE
          value: "10000"
        - name: GRID_MAX_SESSION
          value: "10"
        - name: GRID_TIMEOUT
          value: "150"
        image: selenium/hub:3.6
        name: ds-hub
        ports:
        - containerPort: 4444
        resources: {}
        stdin: true
        tty: true
      restartPolicy: Always
status: {}

and now I want to deploy a new version for example 3.7

The only way I know, to do it - is to change in yaml file:

from

image: selenium/hub:3.6

to

image: selenium/hub:3.7

and in console replace yaml file with new version:

oc replace -f <yml_file_describing_pod>

Maybe is it a better solution to do this? Or maybe pod can upgrade automatically? And how I can do this from web?

-- Slavik Muz
docker
kubernetes
openshift
openshift-origin

2 Answers

1/9/2018

Do you have access to your k8s cluster via kubectl? If yes, you can set the new image for your deployment and perform a rolling update:

kubectl set image deployment/ds-hub ds-hub=selenium/hub:3.7
-- Nebril
Source: StackOverflow

1/9/2018

For an automatic update, you can add an ImageChange-trigger to your Deployment-Config and use selenium/hub:latest as ImageStreamTag-name.

    triggers:
  - type: ImageChange
    imageChangeParams:
      automatic: true 
      from:
        kind: ImageStreamTag
        name: selenium/hub:latest
      containerNames:
        - ds-hub
-- Sabrina Jutz
Source: StackOverflow