I am just starting out with kubernetes
. I have created a simple app which is working fine with the external IP address. It's a mongodb-express
with mongo-db
backend. I am trying to get a domain name mapped to it, instead of the IP address.
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongo-express
labels:
app: mongo-express
spec:
replicas: 1
selector:
matchLabels:
app: mongo-express
template:
metadata:
labels:
app: mongo-express
spec:
containers:
- name: mongo-express
image: mongo-express
ports:
- containerPort: 8081
env:
- name: ME_CONFIG_MONGODB_ADMINUSERNAME
etc
---
apiVersion: v1
kind: Service
metadata:
name: mongo-express-service
spec:
selector:
app: mongo-express
type: LoadBalancer
ports:
- protocol: TCP
port: 80
targetPort: 8081
This was a walk in the park with AWS. Simply created a zone and added the name servers to the domain name provider, however in GCP this does not work. I have created a zone in cloudDNS but cannot seem to map it to the cluster. The documentation is a bit complex for me to understand. Can someone help?
kubernetes ClusterIP 10.28.0.1 <none> 443/TCP 51m
mongo-express-service LoadBalancer 10.28.7.249 34.69.73.210 80:30055/TCP 42m
mongodb-service ClusterIP 10.28.1.163 <none> 27017/TCP 45m
Cloud DNS config is the same as the route53 configuration. You can add the CName record or A record as per requirement.
For a simple use case, you can follow this document which is regarding adding static IP to DNS and mapping the domain.
As you have already exposed the service with type LoadBalancer you can follow from here
Make sure your Nameserver are set correctly
If your nameserver is Cloud DNS: Follow Cloud DNS Quickstart guide to configure DNS A record for your domain name with the reserved IP address of your application.
If your nameserver is another provider: Refer to your DNS service's documentation on setting DNS A records to configure your domain name. If you choose to use Cloud DNS instead, refer to Migrating to Cloud DNS.
Extra :
You can also use the external DNS to auto add the ingress records to Cloud DNS.
Example : https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/gke.md