Skip to content

Instantly share code, notes, and snippets.

@atomatt
Last active October 17, 2022 15:16
Show Gist options
  • Select an option

  • Save atomatt/efe29893b20dfd0cac1bc07a59c88f81 to your computer and use it in GitHub Desktop.

Select an option

Save atomatt/efe29893b20dfd0cac1bc07a59c88f81 to your computer and use it in GitHub Desktop.
Tilt+minikube hack for DNS Ingress

Start minikube with addons - minikube start --addons ingress,ingress-dns

Bootstrap services with Tilt:

$ cat Tiltfile 
ip=str(local('minikube ip')).strip()
tld='{}.nip.io'.format(ip)

# Crudely patch host names to use TLD.
k8s_yaml_content = str(read_file('k8s.yaml'))
k8s_yaml_content = k8s_yaml_content.replace('.TLD', '.'+tld)
k8s_yaml(blob(k8s_yaml_content))

Define your Kubernetes resources in the "k8s.yaml" file and use ".TLD" anywhere you want the nip.io TLD injected.

e.g.

$ cat k8s.yaml
[...]
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx
  labels:
    name: nginx
spec:
  rules:
  - host: nginx.TLD
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: nginx
            port:
              number: 80
$ curl http://nginx.$(minikube ip).nip.io/
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
[...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment