Reputation: 1678
I have referred this tutorial to create deployable image:
I want to use this HELM chart in order to deploy image from directory:
apiVersion: apps/v1
kind: Deployment # Kubernetes resource kind we are creating
metadata:
name: spring-boot-k8s
spec:
selector:
matchLabels:
app: spring-boot-k8s
replicas: 2 # Number of replicas that will be created for this deployment
template:
metadata:
labels:
app: spring-boot-k8s
spec:
containers:
- name: spring-boot-k8s
image: springboot-k8s-example:1.0
# Image that will be used to containers in the cluster
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
# The port that the container is running on in the cluster
How I can deploy the docker image springboot-k8s-example:1.0
from a directory or from a private Docker registry from url link?
Upvotes: 0
Views: 150
Reputation: 1571
Here you will need to create an image pull secret to pull an image from your own repository. I have reproduced your issue and pushed the image to my privet docker registry and then pulled the image successfully.
This could be done by using the below command here I am assuming that you are using docker privet registry :
kubectl create secret docker-registry regcred --docker-server=https://index.docker.io/v1/ --docker-username=<docker-username> --docker-password=<your-password> --docker-email=<docker-email
This will create a secret and now you will need to add it in your deployment manifest so that it could authenticate with privet registry to pull the image.
apiVersion: apps/v1
kind: Deployment # Kubernetes resource kind we are creating
metadata:
name: spring-boot-k8s
spec:
selector:
matchLabels:
app: spring-boot-k8s
replicas: 2 # Number of replicas that will be created for this deployment
template:
metadata:
labels:
app: spring-boot-k8s
spec:
containers:
- name: spring-boot-k8s
image: sidharthpai/springboot-k8s-example:1.0
# Image that will be used to containers in the cluster
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
imagePullSecrets:
- name: regcred
For more reference to create image pull secret : image pull secret
Now to prepare the helm chart you will need to create a chart with relevant name and then configure Deployment.yml & Secret.yml in the helm chart template.Once this is done you will need to configure values.yml.
Deployment.yml (template)
apiVersion: apps/v1
kind: Deployment # Kubernetes resource kind we are creating
metadata:
name: {{ .Values.name}}
spec:
selector:
matchLabels:
app: {{ .Values.app}}
replicas: 2 # Number of replicas that will be created for this deployment
template:
metadata:
labels:
app: {{ .Values.app}}
spec:
containers:
- name: {{ .Values.name}}
image: {{ .Values.image}}
# Image that will be used to containers in the cluster
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
imagePullSecrets:
- name: {{ .Values.secret_name}}
Secret.yml(Template)
apiVersion: v1
data:
.dockerconfigjson: {{ .Values.docker_config}}
kind: Secret
metadata:
name: {{ .Values.secret_name}}
type: kubernetes.io/dockerconfigjson
Values.yml
name: spring-boot-k8s
app: spring-boot-k8s
image: sidharthpai/springboot-k8s-example:1.0
secret_name: regcred
docker_config: <docker-config-value>
Upvotes: 1