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

Add support for kubernetes discovery in dashboard #1362

Merged
merged 24 commits into from Jun 20, 2023

Conversation

yang-xiaodong
Copy link
Member

@yang-xiaodong yang-xiaodong commented Jun 17, 2023

Description:

At the inception of CAP, Kubernetes was not widely used. We used Consul for dashboard discovery to collect data from other nodes, which greatly streamlined the process of viewing data from different nodes in microservices.

According to feedback from our community, more and more people are using Kubernetes as their deployment environment. We plan to support Kubernetes in our dashboard in the next version. At that time, we will provide a new package DotNetCore.CAP.Dashboard.K8s to continue this support.

To run a pod with Kubernetes discovery, you need to have permissions to access the Kubernetes API server. The required configuration is as follows:

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: api-access

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: ns-svc-reader
rules:
- apiGroups: [""]
  resources: ["namespaces", "services"]
  verbs: ["get", "watch", "list"]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: read-pods
subjects:
- kind: ServiceAccount
  name: api-access
  namespace: default
roleRef:
  kind: ClusterRole
  name: ns-svc-reader
  apiGroup: rbac.authorization.k8s.io
  
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-access-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: api-access-app
  template:
    metadata:
      labels:
        app: api-access-app
    spec:
      serviceAccountName: api-access
      containers:
      - name: api-access-container
        image: your_image
        
---
apiVersion: v1
kind: Service
metadata:
  name: api-access-service
spec:
  selector:
    app: api-access-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80

Issue(s) addressed:

Changes:

  • Introduced a new DotNetCore.CAP.Dashboard.K8s NuGet package to support Kubernetes service discovery.
  • Introduced a new service discovery configuration option cap.UseK8sDiscovery() to support configuring Kubernetes service discovery.
  • Redesigned the Node page for the Dashboard, now supporting both Consul and Kubernetes.
  • Renamed cap.UseDiscovery to cap.UseConsulDiscovery to avoid ambiguity with cap.UseK8sDiscovery.
  • Introduced a new configuration option service.AddCapDashboardStandalone() to support running the Dashboard as a standalone pod.

Affected components:

  • Use Consul as node discovery users need to use the new cap.UseConsulDiscovery configuration items.
  • Remove dashbaord legacy brower support

Checklist:

  • I have tested my changes locally
  • I have added necessary documentation (if applicable)
  • I have updated the relevant tests (if applicable)
  • My changes follow the project's code style guidelines

Reviewers:

@yang-xiaodong yang-xiaodong merged commit d6ce0b9 into master Jun 20, 2023
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant