Statefulset - Accessing website deployed on pod

.Hi

I have Minikube on mac machine. I am new to the kubernates. I am doing POC of statefullset feature.

I have deployed a headless service and asp.net core web application (.Net 3.1) .It is simple web site application implemented using MVC.

I wanted to access website deployed on pod. Since there is no cluster ip/external IP, i find it difficult to access my website. I have following kuberantes YAML file.

apiVersion: v1
kind: Service
metadata:
  name: webcacheservice2
  labels:
    app: webcacheservice2
spec:
  ports:
    - port: 80
      name: webcacheservice2
  clusterIP: None
  selector:
    app: webcachepod2
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web2
spec:
  serviceName: webcacheservice2
  replicas: 3
  selector:
    matchLabels:
      app: webcachepod2
  template:
    metadata:
      labels:
        app: webcachepod2
    spec:
      containers:
        - name: webcachesample
          image: docker.io/tbadhe2/test:webcachesample
          ports:
            - containerPort: 80
              name: web2
          volumeMounts:
            - name: www
              mountPath: /usr/share/nginx/html
  volumeClaimTemplates:
    - metadata:
        name: www
      spec:
        accessModes: ["ReadWriteOnce"]
        resources:
          requests:
            storage: 1Gi

kindly assist how i can access web site deployed on pods.

Hi tbadhe2,

I think you should create a nodePort type service to get acess to your pod from the outside.

Best Regards,
Fouscou B.

Please, check your posts in the preview before sending them and also check how it looks like after you send them if you want others to understand your question and get an answer more quickly :slight_smile: You insert codes as code blocks (</> button). I fixed your post.

@fouscou is right. But the answer is also in the documentation: