InvalidImageName for helm chart when pulling image for springboot project from dockerhub - devops

So guys i have helm chart pretty basic with command helm create and i change in values image url to dockerhub url but when it pulls it says invalid image name
image:
repository: https://hub.docker.com/r/markoblazhevski/kiii
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "latest"
my image it has latest tag , the dockerhub repo is public, and i dont know what is wrong, should i add more configurations?
i am pretty new to helm charts so i need a little bit of help
I tried to change the tag or the docker repo link but it says invalid image name

Related

Helm Install from DockerHub image - DockerHub Image download fails

When running the following command:
helm upgrade --cleanup-on-fail \
-- install $releaseName $dockerHubName/$dockerHubRepo:$tag \
-- namespace $namespace \
-- create-namespace \
-- values config.yaml
I get the following error:
Error: Failed to download "$dockerHubName/$dockerHubRepo"
I've also tried with different tags, with semantic versioning (tag="1.0.0") and there's a image with the tag "latest" on the DockerHub repo (which is Public)
This also works with the base JuPyTerHub image jupyterhub/jupyterhub
Based on information from the jupyterhub for kubernetes site, to use a different image from jupyter/docker-stacks, the following steps are required:
Modify your config.yaml file to specify the image. For example:
singleuser:
image:
# You should replace the "latest" tag with a fixed version from:
# https://hub.docker.com/r/jupyter/datascience-notebook/tags/
# Inspect the Dockerfile at:
# https://github.com/jupyter/docker-stacks/tree/HEAD/datascience-notebook/Dockerfile
name: jupyter/datascience-notebook
tag: latest
Apply the changes by following the directions listed in apply the changes.
If you have configured prePuller.hook.enabled, all the nodes in your
cluster will pull the image before the hub is upgraded to let users
use the image. The image pulling may take several minutes to complete,
depending on the size of the image.
Restart your server from JupyterHub control panel if you are already logged in.

Private Docker registry for dependencies in Helm chart

I have a Helm chart that uses Nginx chart as a dependency. Is it possible to specify different repo for pulling the image?
My dependencies:
dependencies:
- name: nginx-ingress
version: "3.15.2"
repository: "https://kubernetes.github.io/ingress-nginx"
condition: master.ingress.create_controller
tags:
- ingressController
What I want to achieve is to make k8s pull image from private Docker registry instead of Docker Hub.
I've checked Helm docs, but couldn't find a corresponding parameter. I understand that I can download the chart and change the value inside, but this is my plan B.
This is possible only if the chart has an option to do it.
If you look at the chart's values.yaml file you can see that it has settings:
controller:
image:
repository: k8s.gcr.io/ingress-nginx/controller
And, correspondingly in the Deployment template:
{{- with .Values.controller.image }}
image: "{{.repository}}:{{ .tag }}{{- if (.digest) -}} #{{.digest}} {{- end -}}"
{{- end }}
So when you deploy the chart, you can add to your deploy-time settings
nginx-ingress:
controller:
image:
repository: docker-mirror.example.com/k8s.gcr.io/ingress-nginx/controller
You can also default this in the parent chart.
Different charts handle this in different ways. The Bitnami charts, for example, let you separately specify the registry and image names, and support a global: { imageRegistry: ... } option. (Which is just used via string concatenation, so if you have a path prefix in your local registry mirror, you can include both parts there.)

Docker image not pulling the latest image from Docker Hub using tag "latest" using Helm Chart

Currently I implemented a test CI/CD pipeline using Jenkins, Docker and Kubernetes. I am using Kubernetes Helm Chart for adding my Kubernetes resources and using Dockerhub as image repository. When I am checking the output of api that I deployed, it's not updated with modified change.
When I checked with the console output of Jenkins, it showing everything successfully. But the latest Docker image is not pulling by using the tag "latest". Still I am getting the older output.
In my Helm Chart values.yaml, I added like following:
imageCredentials:
name: helmchartrepository
registry: <my-registry-name>
username: <my-username>
password: <my-password>
image:
repository: <my-repository>
tag: latest
pullPolicy: Always
And my deployment.yaml referring to these values like the following:
NB: Even if I am using the configuration for pulling latest image from repository by using "latest" , still I am not getting the modified image. And there is no error also. Only issue is pulling the latest docker image from Dockerhub image repository.
How can I resolve this error?
Add date: "{{ .Release.Time.Seconds }}" in your deployment under template/metadata/labels and set imagePullPolicy: Always. Helm will detect the changes in the deployment object and will pull the latest image each time:
template:
metadata:
labels:
app.kubernetes.io/name: {{ .Values.app.frontendName }}
app.kubernetes.io/instance: {{ .Release.Name }}
date: "{{ .Release.Time.Seconds }}"
Run helm upgrade releaseName ./my-chart to upgrade your release
Helm is not able to understand whether the image has been updated or not. Since you are using the fixed tag latest. You can add some labels like date or timestamp in the metadata to identify the change.
In your values.yaml file, in your image, add date as following:
replicaCount: 3
image:
repository: yourRepo/yourImage
pullPolicy: Always
tag: "yourTag"
# Add this
date: "{{ .Release.Time.Seconds }}"

Is there a way to set "imagePullPolicy" for Cloud Run Service?

I would like to be able to automatically update my Google Cloud Run Services once my image has been updated on Google Container Registry.
I need to update multiple Cloud Run services based on the same image (which has a tag of :latest ), so I expected this to work.
# build & push the container image
- name: "gcr.io/kaniko-project/executor:latest"
args: ["--cache=true", "--cache-ttl=48h", "--destination=gcr.io/project/titan:latest"]
Currently, my titan image gets updated but no new Revision is deployed to Cloud Run.
Google Cloud Run does not automatically deploy a revision when you push a new image to a tag reference. There are many good reasons it doesn’t.
When a Cloud Run revision is deployed, it computes the sha256 hash of the image reference.
Therefore when you specify a container image with :latest tag, Cloud Run uses its sha256 reference to deploy and scale out that revision of your service. When you update :latest tag to point to the new image, Cloud Run will still use the previous image. It would be a dangerous and slippery slope otherwise.
If you need to auto-deploy new revisions to Cloud Run based on a new image push, I recommend two solutions:
Make “gcloud beta run deploy” command a step in your Google Cloud Build process. (easy) https://cloud.google.com/run/docs/continuous-deployment
Write a GCF/Run service that deploys your app to Cloud Run every time there’s a new image pushed by subscribing to Google Cloud Build (or GCR) notifications through PubSub. (much harder)
The default pull policy is IfNotPresent which causes the Kubelet to skip pulling an image if it already exists. If you would like to always force a pull, you can do one of the following:
set the imagePullPolicy of the container to Always.
omit the imagePullPolicy and use :latest as the tag for the image to use.
omit the imagePullPolicy and the tag for the image to use.
enable the AlwaysPullImages admission controller.
Note that you should avoid using :latest tag, see Best Practices for Configuration for more information.
For example, creating a YAML file dummy.yaml
apiVersion: v1
kind: Pod
metadata:
name: foo
spec:
containers:
- name: whatever
image: index.docker.io/DOCKER_USER/PRIVATE_REPO_NAME:latest
imagePullPolicy: Always
command: [ "echo", "SUCCESS" ]
imagePullSecrets:
- name: myregistrykey
Then run:
kubectl create -f dummy.yaml

How to use helm charts without internet access

All of us know that helm charts are amazing and make our lives easier.
However, I got a use case when I would like to use helm charts - WITHOUT INTERNET ACCESS
And there are two steps:
Downloading chart from Git
Pulling Docker images from Dockerhub (spefified in values.yaml files)
How can I do this?
Using a helm chart offline involves pulling the chart from the internet then installing it.:
$ helm pull <chart name>
$ ls #The chart will be pulled as a tar to the local directory
$ helm install <whatever release name you want> <chart name>.tgz
For this method to work you'll need all the docker images the chart uses locally as you mentioned.
I know the answer to the first part of my question.
you can actually git clone https://github.com/kubernetes/charts.git all offical charts from github and specify path to a chart (folder) on your filesystem you want to install.
This will be in form of helmfile
execute the command like this:
helmfile -f deployment.yaml sync
cat deployment.yaml
...
repositories:
- name: roboll
url: http://roboll.io/charts
context: example.int.com # kube-context (--kube-context)
releases:
# Prometheus deployment
- name: my_prometheus # name of this release
namespace: monitoring # target namespace
chart: /opt/heml/charts/stable/prometheus # the chart being installed to create this release, referenced by `repository/chart` syntax
values: ["values/values_prometheus_ns_monitoring.yaml"]
set: # values (--set)
- name: rbac.create
value: true
# Grafana deployment
- name: my_grafana # name of this release
namespace: monitoring # target namespace
chart: /opt/heml/charts/stable/grafana
values: ["values/values_grafana_ns_monitoring.yaml"]
So as you can see I have specified some custom values_<software>_ns_monitoring.yaml files.
The second part of my original question is still unanswered.
I want to be able to tell docker to use a local docker image in this section
cat values_grafana_ns_monitoring.yaml
replicas: 1
image:
repository: grafana/grafana
tag: 5.0.4
pullPolicy: IfNotPresent
I have managed to manually copy/paste - then load docker image
so it is visible in my computer - but I can't figure out how to convince
docker + helmfile to use my image. The goal is to process totally offlilne installation.
ANY IDEAS ???
sudo docker images
[sudo] password for jantoth:
REPOSITORY TAG IMAGE ID CREATED SIZE
my_made_up_string/custom_grafana/custom_grafana 5.1.2 917f46a60761 6 days ago 238 MB
Pulling docker images from Dockerhub WITHOUT INTERNET ACCESS
Obviously, that is not possible. However, the problem can be addressed by splitting it into stages:
Pull the docker images from Dockerhub to a system that has internet access.
Save the docker images docker save, copy them to the destination environment where you want to do offline installation and load the images back docker load
Setup a docker registry in the destination environment and tag / push the docker images into this registry. Local docker registry
In the helm charts / kubernetes yaml files, update image references to point to the local docker registry Kubernetes and private docker registry
Alternatively, you can look at offline packaging / deployment tools like Gravity

Resources