1

I have following setup:

  • Private OpenStack Cloud - o̲n̲l̲y̲ Web UI (Horizon) is accessible
    (API is restricted but maybe I could get access)
  • I have used CoreOS with a setup of one master and three nodes
  • Resources are standardized (as default of OpenStack)
  • I followed the getting-started guide for CoreOS (i.e. I'm using the default YAMLs for cloud-config provided) on GitHub

As I read extensions such like Web UI (kube-ui) can be added as Add-On - which I have added (only kube-ui).

Now if I run a test such like simple-nginx I get following output:

creating pods:

$ kubectl run my-nginx --image=nginx --replicas=2 --port=80

creating service:

$ kubectl expose rc my-nginx --port=80 --type=LoadBalancer          
NAME       LABELS         SELECTOR       IP(S)     PORT(S)
my-nginx   run=my-nginx   run=my-nginx             80/TCP

get service info:

$ kubectl describe service my-nginx                                                                                                
Name:           my-nginx
Namespace:      default
Labels:         run=my-nginx
Selector:       run=my-nginx
Type:           LoadBalancer
IP:             10.100.161.90
Port:           <unnamed>   80/TCP
NodePort:       <unnamed>   31170/TCP
Endpoints:      10.244.19.2:80,10.244.44.3:80
Session Affinity:   None
No events.

I can access my service from every(!) external IP of the nodes.

My question now is as follows:

How can access any started service ether with a subdomain and therefore how can I set this configuration (for example I have domain.com as example) or could it be printed out on which node-IP I have to access my service (although I have only two replicas(?!))?

To describe my thoughts more understandable I mean following:

  • given domain: domain.com (pointing to master)
  • start service simple-nginx
  • service can be accessed with simple-nginx.domain.com
x4k3p
  • 113
  • 6

2 Answers2

1

Here is the answer to all these people that see it after 5 years since the question got asked.

Tech got better and now we have ingress in k8s :D.

To make use of subdomains, deploy ingress controller e.g. nginx ingress controller

and create an ingress object:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
spec:
  rules:
  - host: "simple-nginx.domain.com"
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: simple-nginx
            port:
              number: 80

Now all that is left to do, is to create a dns record for *.domain.com and point it to the ingress IP seen in ADDRESS column.

$ kubectl get ingress
NAME          CLASS    HOSTS                      ADDRESS           PORTS   AGE
ingress       <none>   simple-nginx.domain.com    xxx.yyy.zzz.kkk   80      2d20h
Matt
  • 528
  • 3
  • 7
0

You need to do two things:

  • Run the kube-proxy on all nodes you want to access the VIPs (virtual IPs) for the services
  • Point the node's DNS in /etc/resolv.conf to point to the DNS server that is running in the kubernetes cluster.
brendan
  • 116