kyverno icon indicating copy to clipboard operation
kyverno copied to clipboard

Add a new option for profiling Kyverno

Open realshuting opened this issue 2 years ago • 10 comments

Problem Statement

The Kyverno endpoint can be exposed via the loadbalancer type of service. We can add an example service manifest under https://github.com/kyverno/kyverno/wiki/Profiling-Kyverno-on-Kubernetes#expose-the-endpoint-at-the-local-port.

Solution Description

apiVersion: v1
kind: Service
metadata:
  name: pproc-service
  namespace: kyverno
spec:
  selector:
    app: kyverno
  ports:
    - protocol: TCP
      port: 6060
      targetPort: 6060
  type: LoadBalancer

Alternatives

No response

Additional Context

No response

Slack discussion

https://kubernetes.slack.com/archives/CLGR9BJU9/p1657102500335939?thread_ts=1657027928.322689&cid=CLGR9BJU9

Research

  • [X] I have read and followed the documentation AND the troubleshooting guide.
  • [X] I have searched other issues in this repository and mine is not recorded.

realshuting avatar Jul 06 '22 10:07 realshuting

Hey @realshuting, I would like to help resolve this.

anubha-v-ardhan avatar Jul 07 '22 02:07 anubha-v-ardhan

Sorry, but how can I open a PR changing GitHub wiki. Forking the repo doesn't fork the wiki automatically and I failed to find much help on the internet.

anubha-v-ardhan avatar Jul 08 '22 06:07 anubha-v-ardhan

Heyy @anubha-v-ardhan , you could clone the wiki using git clone https://github.com/kyverno/kyverno.wiki.git and make the change I suppose .

anutosh491 avatar Jul 08 '22 10:07 anutosh491

You can also just paste your content into a response here, I suppose.

chipzoller avatar Jul 09 '22 19:07 chipzoller

Hey @anubha-v-ardhan can I make PR for this issue please ?

chetak123 avatar Jul 18 '22 15:07 chetak123

@chetak123 Sure, feel free to assign yourself. unassigning myself....

anubha-v-ardhan avatar Jul 18 '22 16:07 anubha-v-ardhan

@chetak123 - assigned!

realshuting avatar Jul 19 '22 10:07 realshuting

Hello everyone Sorry for the misread but it turns out I can clone the wiki and make changes to my local git repo but I cannot make PR to the main project wiki (because it's not forked with the main project).

There are some workarounds for it like this or this one

But it will be much easier if the project maintainer makes the required revision to the wiki Thanks.

chetak123 avatar Jul 20 '22 04:07 chetak123

Hi @chetak123 - you can also attach the instructions here. I can update the wiki.

realshuting avatar Jul 20 '22 09:07 realshuting

The HTTP endpoint will now be available as a local port.

You can use loadbalancer type of service to expose Kyverno endpoint, an example service manifest is given below:

apiVersion: v1
kind: Service
metadata:
  name: pproc-service
  namespace: kyverno
spec:
  selector:
    app: kyverno
  ports:
    - protocol: TCP
      port: 6060
      targetPort: 6060
  type: LoadBalancer

chetak123 avatar Jul 26 '22 10:07 chetak123

@chetak123 - thanks for your reply.

I see this as an alternative to kubectl portforward solution. Can you add this as another option and attach the entire Expose the endpoint at the local port section in the markdown format?

realshuting avatar Aug 18 '22 10:08 realshuting

Expose the endpoint at the local port

You can get at the application in the pod by port forwarding with kubectl, for example:

$ kubectl -n kyverno get pod
NAME                       READY   STATUS    RESTARTS   AGE
kyverno-7d67c967c6-slbpr   1/1     Running   0          19s
$ kubectl -n kyverno port-forward kyverno-7d67c967c6-slbpr 6060
Forwarding from 127.0.0.1:6060 -> 6060
Forwarding from [::1]:6060 -> 6060

The HTTP endpoint will now be available as a local port.

Alternatively you can use loadbalancer type of service to expose Kyverno endpoint, an example service manifest is given below:

apiVersion: v1
kind: Service
metadata:
  name: pproc-service
  namespace: kyverno
spec:
  selector:
    app: kyverno
  ports:
    - protocol: TCP
      port: 6060
      targetPort: 6060
  type: LoadBalancer

expose.md

Hey @realshuting I have attached the Expose the endpoint section in markdown format in the form of expose.md file attached and the preview can be seen above

chetak123 avatar Aug 22 '22 16:08 chetak123

Cleaned up Markdown below (maintainers can edit the post to copy raw MD):

Expose the endpoint on a local port

You can Kyverno by port forwarding with kubectl, for example:

$ kubectl -n kyverno get pod
NAME                       READY   STATUS    RESTARTS   AGE
kyverno-7d67c967c6-slbpr   1/1     Running   0          19s
$ kubectl -n kyverno port-forward kyverno-7d67c967c6-slbpr 6060
Forwarding from 127.0.0.1:6060 -> 6060
Forwarding from [::1]:6060 -> 6060

The HTTP endpoint will now be available as a local port.

Alternatively, use a Service of type LoadBalancer to expose Kyverno. An example Service manifest is given below:

apiVersion: v1
kind: Service
metadata:
  name: pproc-service
  namespace: kyverno
spec:
  selector:
    app: kyverno
  ports:
    - protocol: TCP
      port: 6060
      targetPort: 6060
  type: LoadBalancer

chipzoller avatar Aug 29 '22 21:08 chipzoller

Updated https://github.com/kyverno/kyverno/wiki/Profiling-Kyverno-on-Kubernetes#expose-the-endpoint-on-a-local-port.

Thanks @chetak123 and Chip!

realshuting avatar Aug 30 '22 14:08 realshuting