Search code examples
azure-devopskubernetes-helmkubectlharbor

How can I make an HELM UPGRADE with specific tag container version?


I am trying through Azure DevOps to launch a Pipeline that specifies the label of a specific version of the container (not latest). How can I do that?

previously to this requirement, I used:

helm upgrade --values=$(System.DefaultWorkingDirectory)/<FOLDER/NAME>.yaml --namespace <NAMESPACE> --install --reset-values --wait <NAME> .

I am trying through Azure DevOps to launch a Pipeline that specifies the label of a specific version of the container (not latest). How can I do that?

At the moment, it gives me errors with the flag "--app-version":

2020-06-25T15:43:51.9947356Z Error: unknown flag: --app-version
2020-06-25T15:43:51.9990453Z 
2020-06-25T15:43:52.0054964Z ##[error]Bash exited with code '1'.

Maybe, another way is download from the harbor repository and make a helm roll to a version with these TAG. But I can´t find the way. I can´t see that clear.

YML:

# Default values for consent-sandbox.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

nameSpace: <NAME>-pre

image:
  repository: <REPO>
  pullPolicy: Always

## Uncomment and remove [] to download image private
imagePullSecrets: []
  # - name: <namePullSecret>
nameOverride: ""
fullnameOverride: ""

serviceAccount:
  # Specifies whether a service account should be created
  create: false
  # The name of the service account to use.
  # If not set and create is true, a name is generated using the fullname template
  name:

podSecurityContext: {}
  # fsGroup: 2000

securityContext: {}
  # capabilities:
  #   drop:
  #   - ALL
  # readOnlyRootFilesystem: true
  # runAsNonRoot: true
  # runAsUser: 1000

containers:
    portName: http
    port: 8080
    protocol: TCP

env:
  APP_NAME: <NAME>
  JAVA_OPTS_EXT: -Djava.security.egd=file:/dev/./urandom -Dcom.sun.net.ssl.checkRevocation=false  -Djavax.net.ssl.trustStore=/etc/truststore/jssecacerts -Djavax.net.ssl.trustStorePassword=changeit
  WILY_MOM_PORT: 5001
  TZ: Europe/Madrid
  spring_cloud_config_uri: https://<CONF>.local
  spring_application_name: <NAME>
  SPRING_CLOUD_CONFIG_PROFILE: pre
  

envSecrets: {}

livenessProbe: {}
  # path: /
  # port: 8080

readinessProbe: {}
  # path: /
  # port: 8080

service:
  type: ClusterIP
  portName: http
  port: 8080
  targetPort: 8080
  containerPort: 8080

secret:
  jks: <JKS>-jks
  jssecacerts: jssecacerts

ingress:
  enabled: false

route:
  enabled: true
  status: ""

  # Default values for openshift-route.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

  annotations:
  # kubernetes.io/acme-tls: "true"
  # haproxy.router.openshift.io/timeout: 5000ms
  # haproxy.router.openshift.io/ip_whitelist: <IP>

  labels:

  host: "<HOST>.paas.cloudcenter.corp"
  path: ""

  wildcardPolicy: None

  nameOverride: ""
  fullnameOverride: ""

  tls:
    enabled: true
    termination: edge
    insecureEdgeTerminationPolicy: "None"
    key:
    certificate:
    caCertificate:
    destinationCACertificate:

  service:
    name: "<NAME"
    targetPort: http
    weight: 100

  alternateBackends: []


resources:
  # We usually recommend not to specify default resources and to leave this as a conscious
  # choice for the user. This also increases chances charts run on environments with little
  # resources, such as Minikube. If you do want to specify resources, uncomment the following
  # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
  limits:
    cpu: 150m
    memory: 1444Mi
  requests:
    cpu: 100m
    memory: 1024Mi

nodeSelector: {}

tolerations: []

affinity: {}


Probably, I need add in the YML:

 containers:
  - name: my_container
    image: my_image:latest
    imagePullPolicy: "Always"

CHART:

apiVersion: v2
name: examplename
description: testing 

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 1.0.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: latest

but...what can I do if I can´t change the YML?


Solution

  • Finally, I use other way with OC client:

    oc patch deploy push-engine --type='json' -p '[{ "op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "registry.sdi.dev.weu.azure.paas.cloudcenter.corp/test-dev/test:0.0.1" }]'