I'm trying to learn Kubernetes fundamentals, and although I've played around with kubectl
and minikube
locally, I'd like to expose the basic nginx docker image, over the internet, on a domain I have access to (for this example, nginx.mydomain.com
), using DigitalOcean managed Kubernetes. My stumbling point seems to be all-networking related (services and ingress controllers).
However, I'd also like to avoid having to spin up tons of cloud resources, and without use too many dependencies to abstract the problem away from me—so no LoadBalancers or Helm please. Right now, the majority of the answers I've seen for problems like this either solve the problem by invoking these two pieces of tooling.
Here's my nginx.deployment.yaml
file:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
strategy:
rollingUpdate:
maxSurge: 1
replicas: 1
selector:
matchLabels:
app: nginx-deployment
template:
metadata:
labels:
app: nginx-deployment
spec:
containers:
- name: nginx-app
image: nginx
ports:
- containerPort: 80
I apply this to my cluster: kubectl apply -f k8s/nginx.deployment.yaml
. My understanding is that is creates an nginx
container, in a pod, able to accept connections on port 80 (ideal for nginx). I also expose my pod using a NodePort
service:
kubectl expose deployment nginx-deployment --port=8080 --type=NodePort --name=nginx-service
From here, I also create an nginx Ingress controller, and apply that via kubectl
also:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: testing-ingress
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: nginx.mydomain.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx-service
port:
number: 8080
I can confirm this ran, but for some reason, the address
field is blank? I take it this shouldn't be the case?
~ % kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
testing-ingress <none> nginx.mydomain.com 80 83m
Given I have then added an A DNS record to bind nginx.mydomain.com
to the DigitalOcean droplet running my node in my cluster, shouldn't I be able to access nginx.mydomain.com
on port 80 and see the nginx welcome page? Right now, I simply get connection refused:
curl http://nginx.mydomain.com
curl: (7) Failed to connect to http://nginx.mydomain.com port 80: Connection refused
What am I missing here?