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

Introduce interactive ArgoCD source plugin #1220

Merged
merged 4 commits into from
Sep 6, 2023

Conversation

pkosiec
Copy link
Member

@pkosiec pkosiec commented Aug 30, 2023

Description

Changes proposed in this pull request:

  • Introduce ArgoCD source plugin
    • Configure ArgoCD notifications on plugin startup
    • Receive interactive notifications from ArgoCD
    • Define triggers and templates based on ArgoCD notification catalog

Questions

  • Cleanup? For now it is manual. Should we introduce a new method for plugins and run it on SIGINT (context cancel)? I'm afraid it can be difficult to fit in time with modifying ConfigMaps and removing annotation for apps for all configurations 🤔

Follow-up PRs

    1. Improvements
    • Enhanced suport for other communication platforms
    • Introduce JSON schemas for configuration and request (done in this PR)
    1. Documentation

Video

Screen.Recording.2023-09-06.at.00.09.36.mp4

(sorry for a long delay when typing admin password - I was looking for it 😅)

BTW just two kubectl commands are supported:
image

Testing

Checkout PR:

gh pr checkout 1220

Build all plugins:

rm -rf /tmp/botkube;  rm /tmp/botkube.yaml; rm -rf /tmp/plugins
PLUGIN_DOWNLOAD_URL_BASE_PATH="http://localhost:64538/plugin-dist" make gen-plugins-index
npx serve --listen 64538

Prepare comm_config.yaml:

communications:
  "default-group":
    socketSlack:
      enabled: true
      appToken: "xapp-"
      botToken: "xoxb-"
      channels:
        "default":
          name: "botkube-demo"
          bindings:
            executors:
              - k8s-default-tools
            sources:
              - argocd

plugins:
  repositories:
    botkube:
       url: http://localhost:64538/plugins-index.yaml

  incomingWebhook:
    enabled: true
    inClusterBaseURL: http://host.k3d.internal:2115

sources:
  'argocd':
    botkube/argocd:
      enabled: true
      context:
        rbac:
          group:
            type: Static
            static:
              values: [*argocd-group]
      config:
        log:
          level: debug
        defaultSubscriptions:
          applications:
            - name: guestbook # your app name
              namespace: argocd

        argoCD:
          uiBaseUrl: http://localhost:8080 # if argo is not exported

For full options check out values.yaml.

Apply these RBAC resources:

Details

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: argo-rbac
rules:
  - apiGroups: [""]
    resources: ["configmaps"]
    verbs: ["get", "update"]
  - apiGroups: ["argoproj.io"]
    resources: ["applications"]
    verbs: ["get", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: argo-rbac
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: argo-rbac
subjects:
- kind: Group
  name: argocd
  apiGroup: rbac.authorization.k8s.io

Go through ArgoCD Getting started doc and install Argo. Do all steps until step 7. Do not sync the app yet.

Run Botkube locally:

export KUBECONFIG=...
export BOTKUBE_SETTINGS_LOG_LEVEL=debug           
export BOTKUBE_PLUGINS_CACHE__DIR="/tmp/plugins"
export BOTKUBE_CONFIG_PATHS="$(pwd)/helm/botkube/values.yaml,$(pwd)/comm_config.yaml"
export BOTKUBE_SETTINGS_KUBECONFIG="${KUBECONFIG}"
export LOG_LEVEL_SOURCE_BOTKUBE_ARGOCD="debug"
go run ./cmd/botkube-agent/main.go

After startup, wait for Argo notification. Sync (deploy the app) according to the guide: https://argo-cd.readthedocs.io/en/stable/getting_started/#7-sync-deploy-the-application

Delete the app

argocd app delete guestbook

Related issue(s)

#1175

@pkosiec pkosiec added enhancement New feature or request hold labels Aug 30, 2023
@pkosiec pkosiec force-pushed the argo-plugin branch 2 times, most recently from 89aa693 to df52b94 Compare September 5, 2023 18:59
@pkosiec pkosiec removed the hold label Sep 5, 2023
@pkosiec pkosiec changed the title Introduce Argo source plugin Introduce interactive Argo source plugin Sep 5, 2023
@pkosiec pkosiec marked this pull request as ready for review September 5, 2023 22:20
@pkosiec pkosiec requested review from PrasadG193 and a team as code owners September 5, 2023 22:20
@huseyinbabal huseyinbabal self-requested a review September 6, 2023 10:19
Copy link
Contributor

@huseyinbabal huseyinbabal left a comment

Choose a reason for hiding this comment

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

Works as expected 🚀 I have a couple of comments;

  • The minor ones on PR
  • The buttons beside get describe dropdown seems, they are tightly coupled with dropdown, but actually they are not. For example, I selected get and tried to click Details to run actual command, however it is automatically executed once selected. Maybe we can rename Details as View in ArgoCD, but not so important.
  • Tested on discord too, works great
    Screenshot 2023-09-06 at 14 20 46
    Screenshot 2023-09-06 at 14 20 59

@pkosiec
Copy link
Member Author

pkosiec commented Sep 6, 2023

@huseyinbabal Thank you Huseyin! the button/dropdown layout is the same as in Kubernetes source, so yeah, they are not coupled. Maybe I'll make the primary button a default one? And yes, I'll change labels. Thank you!

@pkosiec pkosiec force-pushed the argo-plugin branch 2 times, most recently from 1e9272d to 3e94d85 Compare September 6, 2023 13:17
@huseyinbabal huseyinbabal self-requested a review September 6, 2023 13:36
Copy link
Contributor

@huseyinbabal huseyinbabal left a comment

Choose a reason for hiding this comment

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

Re-approved with a minor comment

@pkosiec pkosiec changed the title Introduce interactive Argo source plugin Introduce interactive ArgoCD source plugin Sep 6, 2023
@pkosiec pkosiec enabled auto-merge (squash) September 6, 2023 13:44
@pkosiec pkosiec merged commit 0d151b0 into kubeshop:main Sep 6, 2023
17 checks passed
@pkosiec pkosiec deleted the argo-plugin branch September 6, 2023 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants