Creating services manually or from pod annotations

84 views
Skip to first unread message

Ondřej Hlaváček

unread,
Aug 22, 2022, 7:12:28 AM8/22/22
to Skupper
Sorry for the flood of my questions recently, I hope this is my last for a while. 

For legitimate reasons we run some of the workload as plain pods instead of deployments. I am wondering if it there is a way to set up a service automatically in a similar way (skupper.io/port, skupper.io/proxy annotations). I have tried it and it didn't seem to work. 

If not, I'd still prefer to avoid using Skupper CLI, is there a way to set up the service(s) manually using yaml manifests? 

The reason I'd like to avoid using the CLI that we have an automatic integration for our app that connects to Kubernetes API via a client library and manages the pods/deployments/services on the Kubernetes cluster(s). Adding a CLI there means we'll need to set up an CLI interface, credentials, error handling, etc.

Thanks a lot, Ondra

Fernando Giorgetti

unread,
Aug 22, 2022, 1:18:34 PM8/22/22
to Ondřej Hlaváček, Skupper
Hi Ondra,

You could create a kubernetes service with the appropriate selector labels targeting your pod(s)
and add the skupper.io/proxy annotation to it.

--
You received this message because you are subscribed to the Google Groups "Skupper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skupper+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skupper/5a012add-ba5b-4dc6-8059-c29693376e2en%40googlegroups.com.

Ondřej Hlaváček

unread,
Aug 23, 2022, 8:12:58 AM8/23/22
to Skupper
I am still failing. Here's my example

cat <<EOF | kubectl apply --namespace skupper-test -f -
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config
data:
  nginx.conf: '
events {
}
http {
   server {
       listen 80;
       location / {
           return 200 "Hello world nginx-2!";
       }
   }
}
'
---
apiVersion: v1
kind: Pod
metadata:
  name: nginx-2
spec:
  containers:
  - image: nginx:latest
    name: nginx
    ports:
    - containerPort: 80
      name: web
    volumeMounts:
      - name: config-vol
        mountPath: /etc/nginx/
  volumes:
    - name: config-vol
      configMap:
        name: nginx-config
        items:
          - key: nginx.conf
            path: nginx.conf
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-2
  labels:
    name: nginx-2
  annotations:
    skupper.io/proxy: http
spec:
  ports:
    - name: nginx
      protocol: TCP
      port: 80
      targetPort: 80
  selector:
    name: nginx-2
  type: ClusterIP
EOF


Here are the resources created

kubectl describe service nginx-2 --namespace skupper-test
Name:              nginx-2
Namespace:         skupper-test
Labels:            name=nginx-2
Annotations:       internal.skupper.io/originalAssignedPort: 80:1037
                   internal.skupper.io/originalSelector: name=nginx-2
                   internal.skupper.io/originalTargetPort: 80:80
                   skupper.io/proxy: http
Selector:          application=skupper-router,skupper.io/component=router
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.251.255.124
IPs:               10.251.255.124
Port:              nginx  80/TCP
TargetPort:        1037/TCP
Endpoints:         10.248.0.73:1037
Session Affinity:  None
Events:            <none>

kubectl describe pod nginx-2 --namespace skupper-test
Name:         nginx-2
Namespace:    skupper-test
Priority:     0
Node:         gke-kbc-data-plane-kbc-data-plane-nod-6c0254e5-m9jt/10.10.0.6
Start Time:   Tue, 23 Aug 2022 13:58:37 +0200
Labels:       <none>
Annotations:  <none>
Status:       Running
IP:           10.248.0.74
IPs:
  IP:  10.248.0.74
Containers:
  nginx:
    Container ID:   containerd://609c6fba26fa0f18143b5649fd2285f07366e046ac34a39a87ec9b61994bec4e
    Image:          nginx:latest
    Image ID:       docker.io/library/nginx@sha256:f15eab733ef99f91d1ad3ab6192ded46a15e4e58cf8fb9ddbe6c6618450e683c
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Tue, 23 Aug 2022 13:58:39 +0200
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /etc/nginx/ from config-vol (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-bmndc (ro)


Trying to reach the pod ip and the service ip from a pod

# curl 10.248.0.74
Hello world nginx-2!

# curl 10.251.255.124
curl: (7) Failed to connect to 10.251.255.124 port 80: Connection refused

Fernando Giorgetti

unread,
Aug 23, 2022, 8:21:56 AM8/23/22
to Ondřej Hlaváček, Skupper
Hi Ondra,

I believe you must add the labels to your pod definition, like:

apiVersion: v1
kind: Pod
metadata:
  name: nginx-2
  labels:
    name: nginx-2
spec:
...
...

Let me know if it helps.



--

Fernando Giorgetti

Red Hat

fgio...@redhat.com   

Ondřej Hlaváček

unread,
Aug 23, 2022, 8:58:35 AM8/23/22
to Fernando Giorgetti, Skupper
What a stupid mistake, it works of course. Thanks! 
--
Ondrej Hlavacek
SRE, Keboola 
@keboola
Reply all
Reply to author
Forward
0 new messages