I am trying to deploy java app in minikube and i created local registry and able to push image to local registry. but when i apply my deploymment, pod failed to pull the image from local registry. I need help in resolving the problem
apiVersion: apps/v1
kind: Deployment
metadata:
name: spring-boot-k8s
spec:
selector:
matchLabels:
app: spring-boot-k8s
replicas: 2
template:
metadata:
labels:
app: spring-boot-k8s
spec:
containers:
- name: spring-boot-k8s
image: localhost:5000/springboot-k8s-example:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
You may want to look at this thread on this topic. There are two pieces needed to get minikube to do what you want:
- Use
minikube image build
to get your image to pre-load your image where minikube can get at it.
- Set
imagePullPolicy
to Never
, to force minikube to use your local image and not go back to the public repo for it.
Thanks Rob for oyur help. Earler i am building image using docker and it is not working. I build image using minikube and able to deploy pods. i am trying deploy nodeport service and service deployment successful. but i m not able to access page from browser. i got an error page.
apiVersion: v1
kind: Service
metadata:
name: springboot-k8s-svc
spec:
type: NodePort
selector:
app: spring-boot-k8s
ports:
- port: 80
targetPort: 80
nodePort: 30007
What error page did you get? You should be using the “tunnel” URL and IP address.
Hi Rob,
i got an error page for both url. " This site can’t be reached". I also tried service type as loadbalancer, but i still got same error.
kind: Service
apiVersion: v1
metadata:
name: springboot-k8s-svc
spec:
selector:
app: spring-boot-k8s
ports:
- protocol: “TCP”
port: 8081
targetPort: 80
type: LoadBalancer
externalIPs:
- 192.168.64.2
thanks
Loadbalancer type will not work on minikube. You’ll need to use a NodePort service.