Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to 1.19, refactor for go.opentelemetry.io/otel/sdk 0.32.1 #304

Merged
merged 10 commits into from
Oct 11, 2022

Conversation

viccuad
Copy link
Member

@viccuad viccuad commented Sep 29, 2022

Description

Supersedes #214

  • build: Bump to go 1.19
  • Deps: bump dependencies, this includes go.opentelemetry.io/otel/sdk and related to 0.32.1
  • refactor: Changes for go.opentelemetry.io/otel/sdk 0.32.1

Test

To deploy Kubewarden with opentelemetry:

#!/usr/bin/env bash
set -ex

minikube addons enable ingress

# version at time of writing: cert-manager-v1.9.1
helm install --wait \
    --namespace cert-manager \
    --create-namespace \
    --set installCRDs=true \
    cert-manager jetstack/cert-manager

# version at time of writing:  opentelemetry-operator-0.13.0
helm install --wait \
  --namespace open-telemetry \
  --create-namespace \
  my-opentelemetry-operator open-telemetry/opentelemetry-operator

cat <<EOF > kube-prometheus-stack-values.yaml
prometheus:
  additionalServiceMonitors:
    - name: kubewarden
      selector:
        matchLabels:
          app: kubewarden-policy-server-default
      namespaceSelector:
        matchNames:
          - kubewarden
      endpoints:
        - port: metrics
          interval: 10s
EOF
# version at time of writing: kube-prometheus-stack-40.5.0
helm install --wait \
  --namespace prometheus \
  --create-namespace \
  --values kube-prometheus-stack-values.yaml \
  prometheus prometheus-community/kube-prometheus-stack

kubectl create namespace jaeger

# version at time of writing: jaeger-operator-2.36.0
helm upgrade -i --wait \
  --namespace jaeger \
  jaeger-operator jaegertracing/jaeger-operator \
  --set rbac.clusterRole=true

kubectl apply -f - <<EOF
apiVersion: jaegertracing.io/v1
kind: Jaeger
metadata:
  name: my-open-telemetry
  namespace: jaeger
spec:
  ingress:
    enabled: true
    annotations:
      kubernetes.io/ingress.class: nginx
EOF

helm install --wait \
  --namespace kubewarden \
  --create-namespace \
  kubewarden-crds kubewarden/kubewarden-crds

cat <<EOF > kubewarden-telemetry-values.yaml
telemetry:
  enabled: True
  metrics:
    port: 8080
  tracing:
    jaeger:
      endpoint: "my-open-telemetry-collector.jaeger.svc.cluster.local:14250"
      tls:
        insecure: true
EOF
helm upgrade -i --wait \
  --namespace kubewarden \
  --create-namespace \
  --values kubewarden-telemetry-values.yaml \
  kubewarden-controller kubewarden/kubewarden-controller

helm upgrade -i --wait \
  --namespace kubewarden \
  --create-namespace \
  kubewarden-defaults kubewarden/kubewarden-defaults \
  --set recommendedPolicies.enabled=True \
  --set recommendedPolicies.defaultPolicyMode=monitor \
  --set policyServer.telemetry.enabled=True

Additional Information

Tradeoff

Potential improvement

@viccuad viccuad changed the title Bump to 1.19, refactor for go.opentelemetry.io/otel/sdk == 0.32.1 Bump to 1.19, refactor for go.opentelemetry.io/otel/sdk 0.32.1 Sep 29, 2022
@viccuad viccuad force-pushed the bump-1.19 branch 2 times, most recently from 9ff2f3a to 9751bbd Compare September 30, 2022 12:29
@viccuad viccuad self-assigned this Sep 30, 2022
@viccuad viccuad marked this pull request as ready for review October 4, 2022 12:39
@viccuad viccuad requested a review from a team as a code owner October 4, 2022 12:39
@viccuad
Copy link
Member Author

viccuad commented Oct 4, 2022

I consider this ready for review.

I have failed to properly test open-telemetry for general availability charts, following the listed instructions above, though.

Copy link
Contributor

@raulcabello raulcabello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@viccuad
Copy link
Member Author

viccuad commented Oct 10, 2022

Thanks to @raulcabello, we have the instructions for deploying correctly the GA charts! Missing things were,

  • s/my-open-telemetry-collector/my-open-telemetry in the metadata.name of the Jaeger resource
  • enable rbac.clusterRole for the Jaeger chart

(edited the instructions)

@viccuad
Copy link
Member Author

viccuad commented Oct 10, 2022

Built the controller image with this PR changes:

make docker-build
docker tag controller:latest ghcr.io/viccuad/test/controller:bump-1.19
docker push ghcr.io/viccuad/test/controller:bump-1.19

One can apply it with:

  helm upgrade -i --wait \
    --namespace kubewarden \
    --create-namespace \
    --values kubewarden-telemetry-values.yaml \
    kubewarden-controller kubewarden/kubewarden-controller \
    --set image.repository=ghcr.io/viccuad/test/controller \
    --set image.tag=bump-1.19

Copy link
Member

@jvanz jvanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I can also run the stack locally using changes from this branch and see data in the jaeger and prometheus.

@flavio
Copy link
Member

flavio commented Oct 11, 2022

Great, rebase the PR and then merge it.

Do we need to update our docs explaining how to enable jaeger?

@viccuad
Copy link
Member Author

viccuad commented Oct 11, 2022

We should update the docs, indeed.

We discovered also that after the controller refactor, we aren't publishing the kubewarden_policy_total metrics anymore. Let me have a quick look on where I can call the function to correctly update that metric.

@viccuad
Copy link
Member Author

viccuad commented Oct 11, 2022

I don't see an easy way to re-introduce the kubewarden_policy_total metric, as the reconcile loops are per PolicyServer, or per admission or mutation policies (and we would need to keep the number of them on our own). Moreover, I think it may be more useful to provide that metric per PolicyServer, not 1 for the whole cluster. I am punting on that, will rebase and merge as it is.

Edit; this is no regression as the metric is not listed in https://docs.kubewarden.io/operator-manual/telemetry/metrics/reference.

Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Fixes panic errors.

Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>

Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Fix golangci-lint contextcheck

Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Fix golangci-lint:
```
exitAfterDefer: os.Exit will exit, and `defer func(){...}(...)` will not run (gocritic)
```

Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Policy interface has more than 10 methods, but we aren't gonna change it.

Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
See also:
golangci/golangci-lint#3109

Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Fix "odd number of arguments passed as key-value pairs for logging".
Pass to logr key-value pairs for structured logging.

Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
@viccuad
Copy link
Member Author

viccuad commented Oct 11, 2022

Rebased. TODO:

@viccuad viccuad merged commit 846ced0 into kubewarden:main Oct 11, 2022
@viccuad viccuad deleted the bump-1.19 branch October 11, 2022 13:04
viccuad added a commit to viccuad/docs that referenced this pull request Nov 24, 2022
From kubewarden/kubewarden-controller#304

Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants