### Example Bearer Token Source: https://github.com/projectsveltos/ui-backend/blob/main/README.md An example of a generated bearer token, which is a JWT used for authentication. ```json eyJhbGciOiJSUzI1NiIsImtpZCI6IkVsYW8zRU9BMWw3UTZ2QUpjNGFRLXljcTU4M1NhaXBZd1ZNWXJySkVtMTAifQ.eyJhdWQiOlsiaHR0cHM6Ly9rdWJlcm5ldGVzLmRlZmF1bHQuc3ZjLmNsdXN0ZXIubG9jYWwiXSwiZXhwIjoxNzI4NzE3NjA0LCJpYXQiOjE3Mjg2MzEyMDQsImlzcyI6Imh0dHBzOi8va3ViZXJuZXRlcy5kZWZhdWx0LnN2Yy5jbHVzdGVyLmxvY2FsIiwianRpIjoiZmQ1OWU4OTctODZlNS00MDQ4LWEwZjAtMDMxYjM5MjVlYjQwIiwia3ViZXJuZXRlcy5pbyI6eyJuYW1lc3BhY2UiOiJwbGF0Zm9ybSIsInNlcnZpY2VhY2NvdW50Ijp7Im5hbWUiOiJtZ2lhbmx1YyIsInVpZCI6ImJjZWUwZDEwLWM2MTQtNDIzNi1iNmZmLTAyYWU2M2M1MjcxZiJ9fSwibmJmIjoxNzI4NjMxMjA0LCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6cGxhdGZvcm06bWdpYW5sdWMifQ.JlEN38Whyb4mlNsWkC4RAQ82dVUJmWvmdvar7VVxEw2SUgoQthQQPsV-l28bGYpuQspFlsdaO2JRdhm6MGctlMJziweHHm3PNv_RBnFMPRQ01y7ciaRZXE7HEB3sAndvBEQKNWyo4wmmyRnEE2tR79ICQRTLmuWO17MjRIZFChXMHsCsam5OsuE6mE1fj3RSUSbvfRbQwrsTcWOrnYxzquyNVyJyOKxQ97Nm175rez5x9EflHPwueYu5FmNgz3cxMsdkHwkrMnhMqMyNN8WBqKUrju-gPJ9GB-cOcrR_38JyeQBPXYTo9J0tueIWEyaiwKvmPqAsnyHKPT5p-7hFCQ ``` -------------------------------- ### Get Sveltos Clusters Source: https://github.com/projectsveltos/ui-backend/blob/main/README.md Retrieves a list of Sveltos clusters. Supports filtering by namespace, name, and labels, as well as pagination. ```APIDOC /sveltosclusters Filters: - namespace=: Filter by namespace name. - name=: Filter by cluster name. - labels=: Filter by label selector. Pagination: - limit=: Number of clusters to return. - skip=: Number of clusters to skip. Example Request: http://localhost:9000/sveltosclusters?limit=1&skip=0&namespace=mgmt&name=mgmt Example Response: { "totalClusters": 1, "managedClusters": [ { "namespace": "mgmt", "name": "mgmt", "clusterInfo": { "labels": null, "version": "v1.29.0", "ready": true, "failureMessage": null } } ] } ``` -------------------------------- ### Get All Profiles Source: https://github.com/projectsveltos/ui-backend/blob/main/README.md Retrieves all Sveltos profiles, optionally filtered by namespace or name, and grouped by tier. The response includes profile details such as kind, namespace, name, dependencies, and dependents. ```APIDOC GET /profiles Query Parameters: - namespace=: Filters profiles by namespace containing the specified string. - name=: Filters profiles by name containing the specified string. Response Body: Returns profiles grouped by tier. Each profile includes: - Kind: 'ClusterProfile' or 'Profile' - Namespace: Namespace of the profile (empty for ClusterProfiles) - Name: Name of the profile - Dependencies: List of profiles the profile depends on - Dependents: List of profiles that depend on this profile Example Response Structure: { "100": { "totalProfiles": 4, "profiles": [ { "kind": "ClusterProfile", "namespace": "", "name": "deploy-kyverno", "dependencies": [], "dependents": [ { "kind": "ClusterProfile", "name": "prometheus-grafana", "apiVersion": "config.projectsveltos.io/v1beta1" } ] }, // ... other profiles ] }, // ... other tiers } ``` -------------------------------- ### Get ClusterAPI Clusters Source: https://github.com/projectsveltos/ui-backend/blob/main/README.md Retrieves a list of ClusterAPI powered clusters. Supports filtering by namespace, name, and labels, as well as pagination. ```APIDOC /capiclusters Filters: - namespace=: Filter by namespace name. - name=: Filter by cluster name. - labels=: Filter by label selector. Pagination: - limit=: Number of clusters to return. - skip=: Number of clusters to skip. Example Request: http://localhost:9000/capiclusters?limit=1&skip=0&namespace=default&labels=env:fv,cluster.x-k8s.io%2Fcluster-name:clusterapi-workload Example Response: { "totalClusters": 1, "managedClusters": [ { "namespace": "default", "name": "clusterapi-workload", "clusterInfo": { "labels": { "cluster.x-k8s.io/cluster-name": "clusterapi-workload", "env": "fv", "topology.cluster.x-k8s.io/owned": "" }, "version": "v1.27.0", "ready": true, "failureMessage": null } } ] } ``` -------------------------------- ### Get Specific Profile Instance Source: https://github.com/projectsveltos/ui-backend/blob/main/README.md Retrieves a specific Sveltos profile instance based on its namespace, name, and kind. The response includes detailed information about the profile, its spec, and matching clusters with feature statuses. ```APIDOC GET /profile?namespace=&name=&kind= Query Parameters: - namespace=: Namespace of the profile (required for 'Profile' kind, optional for 'ClusterProfile'). - name=: Name of the profile. - kind=: Kind of the profile ('ClusterProfile' or 'Profile'). Response Body: Returns the profile instance details, including: - Kind: Kind of the profile - Namespace: Namespace of the profile - Name: Name of the profile - Dependencies: List of profiles the profile depends on - Dependents: List of profiles that depend on this profile - Spec: The profile's specification (e.g., clusterSelector, syncMode, policyRefs, helmCharts) - MatchingClusters: List of clusters matching the profile, with their feature statuses. Example Response Structure: { "matchingClusters": [ { "cluster": { "kind": "Cluster", "namespace": "default", "name": "clusterapi-workload", "apiVersion": "cluster.x-k8s.io/v1beta1" }, "clusterFeatureSummaries": [ { "featureID": "Resources", "status": "Provisioned" }, { "featureID": "Helm", "status": "FailedNonRetriable", "failureMessage": "cannot manage chart kyverno/kyverno-latest. ClusterSummary deploy-kyverno-capi-clusterapi-workload managing it." } ] } ], "spec": { "clusterSelector": { "matchLabels": { "env": "fv" } }, "syncMode": "Continuous", "tier": 100, "stopMatchingBehavior": "WithdrawPolicies", "dependsOn": [ "deploy-kyverno" ], "policyRefs": [ { "namespace": "default", "name": "disallow-latest-tag", "kind": "ConfigMap", "deploymentType": "Remote" }, { "namespace": "default", "name": "disallow-empty-ingress", "kind": "ConfigMap", "deploymentType": "Remote" } ], "helmCharts": [ { "repositoryURL": "https://kyverno.github.io/kyverno/", "repositoryName": "kyverno", "chartName": "kyverno/kyverno", "chartVersion": "v3.2.6", "releaseName": "kyverno-latest", "releaseNamespace": "kyverno", "helmChartAction": "Install" } ] } } ``` -------------------------------- ### Get Helm Releases Source: https://github.com/projectsveltos/ui-backend/blob/main/README.md Retrieves a list of Helm releases deployed in a specified cluster. Supports pagination via 'limit' and 'skip' parameters. The cluster type can be 'capi' for ClusterAPI or 'sveltos' for SveltosClusters. ```APIDOC /helmcharts?namespace=&name=&type=&limit=&skip= Parameters: - namespace: The namespace of the cluster. - name: The name of the cluster. - type: The type of the cluster ('capi' or 'sveltos'). - limit: (Optional) The maximum number of Helm releases to return. - skip: (Optional) The number of Helm releases to skip from the beginning. Example Request: http://localhost:9000/helmcharts?namespace=default&name=clusterapi-workload&type=capi Example Response: { "totalHelmReleases": 4, "helmReleases": [ { "repoURL": "https://prometheus-community.github.io/helm-charts", "releaseName": "prometheus", "namespace": "prometheus", "chartVersion": "23.4.0", "icon": "https://raw.githubusercontent.com/prometheus/prometheus.github.io/master/assets/prometheus_logo-cb55bb5c346.png", "lastAppliedTime": "2024-04-28T13:49:29Z", "profileName": "ClusterProfile/prometheus-grafana" }, { "repoURL": "https://grafana.github.io/helm-charts", "releaseName": "grafana", "namespace": "grafana", "chartVersion": "6.58.9", "icon": "https://raw.githubusercontent.com/grafana/grafana/master/public/img/logo_transparent_400x.png", "lastAppliedTime": "2024-04-28T13:49:38Z", "profileName": "ClusterProfile/prometheus-grafana" }, { "repoURL": "https://kyverno.github.io/kyverno/", "releaseName": "kyverno-latest", "namespace": "kyverno", "chartVersion": "3.1.4", "icon": "https://github.com/kyverno/kyverno/raw/main/img/logo.png", "lastAppliedTime": "2024-04-28T13:49:32Z", "profileName": "ClusterProfile/deploy-kyverno" }, { "repoURL": "https://helm.nginx.com/stable/", "releaseName": "nginx-latest", "namespace": "nginx", "chartVersion": "1.1.3", "icon": "https://raw.githubusercontent.com/nginxinc/kubernetes-ingress/v3.4.3/charts/nginx-ingress/chart-icon.png", "lastAppliedTime": "2024-04-28T13:49:36Z", "profileName": "ClusterProfile/nginx" } ] } ``` -------------------------------- ### Get Kubernetes Resources Source: https://github.com/projectsveltos/ui-backend/blob/main/README.md Retrieves a list of Kubernetes resources deployed in a specified cluster. Supports pagination via 'limit' and 'skip' parameters. The cluster type can be 'capi' for ClusterAPI or 'sveltos' for SveltosClusters. ```APIDOC /resources?namespace=&name=&type=&limit=&skip= Parameters: - namespace: The namespace of the cluster. - name: The name of the cluster. - type: The type of the cluster ('capi' or 'sveltos'). - limit: (Optional) The maximum number of Kubernetes resources to return. - skip: (Optional) The number of Kubernetes resources to skip from the beginning. Example Request: http://localhost:9000/resources?namespace=default&name=clusterapi-workload&type=capi Example Response: { "totalResources": 2, "resources": [ { "name": "nginx", "group": "", "kind": "Namespace", "version": "v1", "lastAppliedTime": "2024-04-28T13:52:26Z", "profileNames": [ "ClusterProfile/deploy-resources" ] }, { "name": "", "group": "", "kind": "", "version": "", "profileNames": null } ] } ``` -------------------------------- ### Get Cluster Status Source: https://github.com/projectsveltos/ui-backend/blob/main/README.md Retrieves the status of deployed profiles within a specified cluster. Supports pagination via 'limit' and 'skip' parameters. The cluster type can be 'capi' for ClusterAPI or 'sveltos' for SveltosClusters. ```APIDOC /getClusterStatus?namespace=&name=&type=&limit=&skip= Parameters: - namespace: The namespace of the cluster. - name: The name of the cluster. - type: The type of the cluster ('capi' or 'sveltos'). - limit: (Optional) The maximum number of cluster statuses to return. - skip: (Optional) The number of cluster statuses to skip from the beginning. Example Request: http://localhost:9000/resources?namespace=default&name=clusterapi-workload&type=capi Example Response: { "profiles": [ { "profileName": "deploy-kyverno", "profileType": "ClusterProfile", "featureID": "Helm", "status": "Provisioned" }, { "profileName": "deploy-resources", "profileType": "ClusterProfile", "featureID": "Resources", "status": "Provisioned" }, { "profileName": "nginx", "profileType": "ClusterProfile", "featureID": "Helm", "status": "Provisioned" } ], "totalResources": 3 } ``` -------------------------------- ### Create Service Account Source: https://github.com/projectsveltos/ui-backend/blob/main/README.md Creates a new service account in a specified Kubernetes namespace. This is the first step in setting up authentication for the Sveltos UI Backend. ```bash kubectl create sa -n ``` -------------------------------- ### Authorization Header Source: https://github.com/projectsveltos/ui-backend/blob/main/README.md Explains how to authenticate requests to the backend service using an Authorization header with a Bearer token. ```APIDOC Authorization: Bearer ``` -------------------------------- ### Create Cluster Role Binding Source: https://github.com/projectsveltos/ui-backend/blob/main/README.md Grants a service account permissions to access the Calico Enterprise Manager UI and a Calico Enterprise cluster role. This is crucial for authorizing the service account. ```bash kubectl create clusterrolebinding --clusterrole --serviceaccount : ``` -------------------------------- ### Create Bearer Token Source: https://github.com/projectsveltos/ui-backend/blob/main/README.md Generates a bearer token for a service account with a specified duration. This token is used for authenticating with the Sveltos UI Backend. ```bash kubectl create token sveltos --duration=24h ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.