Pod initialization + tunneling service

Hi all.

I am playing with pod initialization. Initial setup is minikube, I have Deployment + Service. When i run “minikube service grafana-service --url” i can access grafana. But for pod initialization I had to switch to Pod type. So instead of Deployment I have now Pod. Pod is also pointing same Service or vice versa service is now looking for Pod. But when i do “minikube service grafana-service --url” I cant access grafana. Any idea what I am doing wrong?

apiVersion: v1
kind: Pod
metadata:
  name: grafana
spec:
  initContainers:
  - name: init-plugins
    image: busybox:1.28
    command:
      - do some my logic
  containers:
  - name: grafana
    image: grafana/grafana:latest
    ports:
      - containerPort: 3000

---
#apiVersion: apps/v1
#kind: Deployment
#metadata:
#  name: grafana
#spec:
#  selector:
#    matchLabels:
#      app: grafana
#  replicas: 1
#  template:
#    metadata:
#      labels:
#        app: grafana
#    spec:
#      containers:
#        - name: grafana
#          image: grafana/grafana:latest
#          ports:
#            - containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  name: grafana-service
spec:
  type: LoadBalancer
  ports:
    - port: 3000
      targetPort: 3000
      protocol: TCP
  selector:
    app: grafana
---

The service matches the pod using the pod labels.

Notice in the deployment metadata you have a label app=grafana but the pod has no label.

Regardless I would use a deployment and not pod but that’s out of the scope of your query.

L

Just to clarify in the deployment you have

template:
#    metadata:
#      labels:
#        app: grafana

The pod has no label

Nice. The label was missing. Btw I thought I was trying that. But i put it on different place. Now its working I put it in metadata.

Thanks

1 Like