Kubernetes LoadBalancer service is not working

9/25/2019

I am just getting started with kubernetes and have basic understanding of it. I have created a cluster on my local machine using kubeadm with 2 nodes and one master virtualbox machines.

I created a simple deployment and LoadBalancer service as reference using this configuration.

apiVersion: v1
kind: Service
metadata:
  name: helloworld-http
spec:
  type: LoadBalancer
  ports:
    - port: 8080
      targetPort: 80
  externalIPs:
    - 192.168.56.101
  selector:
    run: helloworld

---

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    run: helloworld
  name: helloworld-deploy
spec:
  replicas: 2
  selector:
    matchLabels:
      run: helloworld
  template:
    metadata:
      labels:
        run: helloworld
    spec:
      containers:
      - image: tutum/hello-world
        name: helloworld
        ports:
        - containerPort: 80

Everything works fine and I am able to access helloworld-deploy via helloworld-http service on my host machine.

Now what I am trying to do is install kubernetes-dashboard using this configuration. I want to update this

kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
spec:
  ports:
    - port: 443
      targetPort: 8443
  selector:
    k8s-app: kubernetes-dashboard

service configuration same as my reference configuration above so that I can access dashboard on my host machine without kubectl proxy. Here is configuration I am trying to replace original one with.

kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
spec:
  type: LoadBalancer
  ports:
    - port: 443
      targetPort: 8443
  externalIPs:
    - 192.168.56.101
  selector:
    k8s-app: kubernetes-dashboard

i updated service type to LoadBalancer and assigned it an external IP. But it does not work. i have also tried changing port to 80 but no luck. I don't know if this is the case with dashboard configuration or I am missing something. Any kind of help and suggestions are appreciated.

-- Nafees Anwar
kubernetes
kubernetes-dashboard
kubernetes-service

0 Answers