Kubernetes deployment not exposed

12/4/2018

For some reason, this specific deployment does not expose its service to the outside world. I'm pretty sure my syntax is ok since I use a similar set of files for a deployment only using TCP. I suspect having both TCP and UDP is kind of causing a problem. What's weird is if I run manually the docker in one of the worker, it works:

 docker run -p 27015:27015 -p 27015:27015/udp -e STEAM_ACCOUNT_TOKEN=XXXXXXXXXXXXXXXXXX grido/csgo-edge

Service.yaml

apiVersion: v1
kind: Service
metadata:
  name: csgo200
spec:
  selector:
    app: csgo200
  type: NodePort
  ports:
  - name: udpcsgo1
    port: 27015
    protocol: UDP
  - name: tcpcsgo1
    port: 27015
    protocol: TCP

deployment.yaml

apiVersion: apps/v1 # for versions before 1.9.0 use 
apps/v1beta2
kind: Deployment
metadata:
  name: csgo200
spec:
  selector:
    matchLabels:
      app: csgo200
  replicas: 1 
  template:
    metadata:
      labels:
        app: csgo200
    spec:
  containers:
  - name: csgo200
    image: grido/csgo-edge
    ports:
    - name: tcpcsgo200
      containerPort: 27015
      protocol: TCP
    - name: udpcsgo200
      containerPort: 27015
      protocol: UDP
    env:
    - name: STEAM_ACCOUNT_TOKEN
      value: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

[root@master ~]# kubectl describe svc csgo200

Name:                     csgo200
Namespace:                default
Labels:                   <none>
Annotations:              kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"v1","kind":"Service","metadata": 
{"annotations":{},"name":"csgo200","namespace":"default"},"spec":{"ports": 
[{"name":"udpcsgo...
Selector:                 app=csgo200
Type:                     NodePort
IP:                       10.97.122.32
Port:                     udpcsgo1  27015/UDP
TargetPort:               27015/UDP
NodePort:                 udpcsgo1  31314/UDP
Endpoints:                192.168.1.37:27015
Port:                     tcpcsgo1  27015/TCP
TargetPort:               27015/TCP
NodePort:                 tcpcsgo1  31314/TCP
Endpoints:                192.168.1.37:27015
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>
-- Mathieu Duperré
docker
kubernetes
yaml

1 Answer

12/4/2018

Your service type is declared as NodePort which makes your service available on your nodes. Check service types, I would recommend to use LoadBalancer type

-- gonzalesraul
Source: StackOverflow