forked from kubernetes-sigs/kind
-
Notifications
You must be signed in to change notification settings - Fork 0
Access your services inside the cluster
Antonio Ojea edited this page Sep 13, 2019
·
2 revisions
If you are using Linux you should follow this fantastic tutorial from @mauilion
https://mauilion.dev/posts/kind-metallb/
If you are using Windows or Mac you have to deal with the problems of the docker limitations on those platforms
There are different alternatives, one is using the HostPort feature to expose Pods ports, but has the limitation that you have to know in advance which node will host the Pod.
https://github.com/kubernetes-sigs/kind/pull/637#issuecomment-531108592
An example can be:
kind: Cluster
apiVersion: kind.sigs.k8s.io/v1alpha3
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 80
hostPort: 80
and deploying the service using HostPort to expose the port:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-httpd
spec:
selector:
matchLabels:
run: my-httpd
replicas: 1
template:
metadata:
labels:
run: my-httpd
spec:
containers:
- name: httpd
image: httpd:2-alpine
ports:
- containerPort: 80
hostPort: 80---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-httpd
spec:
selector:
matchLabels:
run: my-httpd
replicas: 1
template:
metadata:
labels:
run: my-httpd
spec:
containers:
- name: httpd
image: httpd:2-alpine
ports:
- containerPort: 80
hostPort: 80
Instead of exposing the POD port directly, you can go with more advanced alternatives like Contour