microk8s Kubernetes Service connection refused microk8s Kubernetes Service connection refused kubernetes kubernetes

microk8s Kubernetes Service connection refused


It's due to you are using the ClusterIP which is only accessible internally from CLuster.

Here you require the Nginx ingress controller to expose the service. Or you can try with the Host IP once to connect with the service.

You can also try the command

kubectl port-forward svc/hello 8080:8080

once the port is forwarded you can hit the curl on localhost:8080.

However, for production use-case it's always suggested to use the ingress for managing the cluster traffic.

Ingress basically work as the Proxy it's same as Nginx.

Ingress is configuration object which managed by the Ingress controller. When you enable the ingress you require the Ingress controller in minikube it will be there however for other Cluster on GKE & EKS you have to setup manually.

Here is good example for the implementation of the ingress in minikube :

https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/

ingress example

apiVersion: networking.k8s.io/v1kind: Ingressmetadata:  name: example-ingress  annotations:spec:  rules:    - host: hello-world.info      http:        paths:          - path: /            backend:              service:                name: hello                port:                  number: 8080


Sounds like you need an ingress add-on, which will let you create rules to access your service via HTTPS/HTTP.

First enable ingress:

    microk8s enable ingress

Then add an ingress rule to your yaml file, such as:

apiVersion: networking.k8s.io/v1beta1kind: Ingressmetadata:  name: http-ingressspec:  rules:  - http:      paths:      - path: /        backend:          serviceName: hello          servicePort: 80

Alternatively, you can just expose your port 8000, since you're working locally, as explained here.


Django doesn't respond.

change

CMD python3 manage.py runserver

with

CMD python3 manage.py runserver 0.0.0.0:8000

also add 0.0.0.0 to ALLOWED_HOSTS.