openanalytics / shinyproxy-operator

Easily run ShinyProxy on a Kubernetes cluster
https://shinyproxy.io
Apache License 2.0
38 stars 10 forks source link

Shinyproxy without Ingress resource #49

Open Pyodin opened 6 months ago

Pyodin commented 6 months ago

Hello,

I'm currently deploying ShinyProxy in my Kubernetes cluster where we use Contour as our Ingress controller. Since we do not use an IngressClass, the typical ingress setup does not apply in our case. I attempted the basic namespaced deployment as outlined in the shinyproxy-operator docs, but since an ingress wasn't created, I am unable to access my resources.

I'm looking to expose my Shiny applications using an HttpProxy instead. However, I'm uncertain about where my proxy should point to. Here is the output of all resources deployed with the shinyproxy-operator/docs/deployment/overlays/1-namespaced deployment in the shinyproxy namespace:

kubectl get all -n shinyproxy
NAME                                       READY   STATUS    RESTARTS   AGE
pod/redis-node-0                           2/2     Running   0          19h
pod/redis-node-1                           2/2     Running   0          19h
pod/redis-node-2                           2/2     Running   0          19h
pod/shinyproxy-operator-5c8fdd65f4-25b6n   1/1     Running   0          19h

NAME                     TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)              AGE
service/redis            ClusterIP   100.64.84.47   <none>        6379/TCP,26379/TCP   19h
service/redis-headless   ClusterIP   None           <none>        6379/TCP,26379/TCP   19h

NAME                                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/shinyproxy-operator   1/1     1            1           19h

NAME                                             DESIRED   CURRENT   READY   AGE
replicaset.apps/shinyproxy-operator-5c8fdd65f4   1         1         1       19h

NAME                          READY   AGE
statefulset.apps/redis-node   3/3     19h

Could you guide me on how to configure the HttpProxy to correctly route traffic to the Shiny applications? Any examples or documentation would be greatly appreciated.

For information, a httpproxy looks just like an Ingress resource:

apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
  name: shinyproxy
  namespace: shinyproxy
spec:
  routes:
  - conditions:
    - prefix: /
    services:
    - name:   ???
      port: 80
  virtualhost:
    fqdn: my-shinyproxy-application.example.com
    tls:
      secretName: my-shiny-secret

Thank you in advance for your assistance.

Paul

LEDfan commented 6 months ago

Hi, it seems you don't have a ShinyProxy instance yet. If you apply this file https://github.com/openanalytics/shinyproxy-operator/blob/master/docs/deployment/overlays/1-namespaced/resources/shinyproxy.shinyproxy.yaml , a ShinyProxy server will be started. Once it's ready, a service sp-shinyproxy will be created and you can point traffic to that service.

Once you deployed the ShinyProxy server, you'll see the following resources:

kubectl get all -n shinyproxy
NAME                                                                  READY   STATUS    RESTARTS   AGE
pod/redis-node-0                                                      2/2     Running   0          6m17s
pod/redis-node-1                                                      2/2     Running   0          5m40s
pod/redis-node-2                                                      2/2     Running   0          5m18s
pod/shinyproxy-operator-7c977465d4-b4krx                              1/1     Running   0          6m17s
pod/sp-shinyproxy-rs-c76f66adbe6d58fe9d4100aef7e56ca03f3b703f-q42r6   1/1     Running   0          5m40s

NAME                        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)              AGE
service/redis               ClusterIP   10.100.187.103   <none>        6379/TCP,26379/TCP   6m17s
service/redis-headless      ClusterIP   None             <none>        6379/TCP,26379/TCP   6m17s
service/sp-shinyproxy-svc   ClusterIP   10.103.224.188   <none>        80/TCP               4m28s

NAME                                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/shinyproxy-operator   1/1     1            1           6m17s

NAME                                                                        DESIRED   CURRENT   READY   AGE
replicaset.apps/shinyproxy-operator-7c977465d4                              1         1         1       6m17s
replicaset.apps/sp-shinyproxy-rs-c76f66adbe6d58fe9d4100aef7e56ca03f3b703f   1         1         1       5m40s

NAME                          READY   AGE
statefulset.apps/redis-node   3/3     6m17s

You can now point your HTTPProxy to sp-shinyproxy-svc

mth003 commented 4 months ago

@LEDfan Hi, I'm attempting to do something similar here using an Istio virtual service.

---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: sp-virtualservice
  namespace: shinyproxy-dev
spec:
  gateways:
  - istio-system/default-gateway
  hosts:
  - shinyproxy.local
  http:
  - headers:
      request:
        set:
          X-Forwarded-Proto: https
    route:
    - destination:
        host: sp-shinyproxy-svc
        port:
          number: 8080 

How would you recommend I add the above? Would this need to be done via the kubernetesIngressPatches?

Thanks, Mitch

LEDfan commented 4 months ago

Hi @mth003 the kubernetesIngressPatches property can only patch the ingress resources created by the operator, a VirtualService is a different kind and cannot be created or patched by the operator. You'll have to create it yourselves, outside the operator.