0.2.3 • Published 2 days ago

@veecode-platform/backstage-plugin-cluster-explorer v0.2.3

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
2 days ago

Cluster Explorer Plugin

The Cluster plugin has two approaches:

  • A list of the Clusters available in your catalog

  • A k8s cluster overview with all its data and relationships within the catalog.

⚠️ It is important to note that the Cluster is a Kind customized by the VeeCode Platform and therefore it requires the installation of the veecode-platform-common plugin in order to work.

To install the veecode-platform-common plugin click here.

Okay, given that you already have a properly configured environment, let's start our installation.

Get Started

cd packages/app
yarn add @veecode-platform/plugin-cluster-explorer

Now, in the file packages > app > src > App.tsx:

...
+ import { clusterExplorerPage } from '@veecode-platform/plugin-cluster-explorer';

...

const routes = (
<FlatRoutes>
+ <Route path="/cluster-explorer" element={<clusterExplorerPage/>}/>
</FlatRoutes>
)
...

To add a menu to your sidebar, just follow these steps: packages > app > src > components > Root > Root.tsx

In the example, we've added an external icon, using the lib react-icons.

cd packages/app
yarn add react-icons
...
+ import { Imcluster } from "react-icons/im";

...

export const Root = ({ children }: PropsWithChildren<{}>) => (
  <SidebarPage>
    <Sidebar>
      <SidebarLogo />
      <SidebarGroup label="Search" icon={<SearchIcon />} to="/search">
        <SidebarSearchModal />
      </SidebarGroup>
      <SidebarDivider />
      <SidebarGroup label="Menu" icon={<MenuIcon />}>
        <SidebarItem icon={HomeIcon} to="catalog" text="Home" />
        <SidebarItem icon={ExtensionIcon} to="api-docs" text="APIs" />
        <SidebarItem icon={LibraryBooks} to="docs" text="Docs" />
+        <SidebarItem icon={Imcluster} to="cluster-explorer" text="clusters" />
        <SidebarItem icon={CreateComponentIcon} to="create" text="Create..." />
        <SidebarDivider />
        <SidebarScrollWrapper>
          <SidebarItem icon={MapIcon} to="tech-radar" text="Tech Radar" />
        </SidebarScrollWrapper>
      </SidebarGroup>
      <SidebarSpace />
      <SidebarDivider />
      <SidebarGroup
        label="Settings"
        icon={<UserSettingsSignInAvatar />}
        to="/settings"
      >
        <SidebarSettings />
      </SidebarGroup>
    </Sidebar>
    {children}
  </SidebarPage>
);

Or you can create a "Resources" menu and add "clusters" as a submenu:

...

+ import BusinessIcon from '@material-ui/icons/Business';
+ import { Imcluster } from "react-icons/im";

...

export const Root = ({ children }: PropsWithChildren<{}>) => (
  <SidebarPage>
    <Sidebar>
      <SidebarLogo />
      <SidebarGroup label="Search" icon={<SearchIcon />} to="/search">
        <SidebarSearchModal />
      </SidebarGroup>
      <SidebarDivider />
      <SidebarGroup label="Menu" icon={<MenuIcon />}>
        <SidebarItem icon={HomeIcon} to="catalog" text="Home" />
        <SidebarItem icon={ExtensionIcon} to="api-docs" text="APIs" />
        <SidebarItem icon={LibraryBooks} to="docs" text="Docs" />
+          <SidebarItem icon={BusinessIcon} text="Resources">
+            <SidebarSubmenu title="">
+              <SidebarDivider />
+              <SidebarSubmenuItem
+                title="clusters"
+                to="cluster-explorer"
+                icon={Imcluster}
+              />
+
+            </SidebarSubmenu>
+          </SidebarItem>
        <SidebarItem icon={CreateComponentIcon} to="create" text="Create..." />
        <SidebarDivider />
        <SidebarScrollWrapper>
          <SidebarItem icon={MapIcon} to="tech-radar" text="Tech Radar" />
        </SidebarScrollWrapper>
      </SidebarGroup>
      <SidebarSpace />
      <SidebarDivider />
      <SidebarGroup
        label="Settings"
        icon={<UserSettingsSignInAvatar />}
        to="/settings"
      >
        <SidebarSettings />
      </SidebarGroup>
    </Sidebar>
    {children}
  </SidebarPage>
);

And that's the view:

By clicking on the icon in the side menu:

  • cluster Listing:

list

  • cluster Overview:

overview

1- Setting up the kubernetes config in the app-config.yaml:

kubernetes:
  serviceLocatorMethod:
    type: multiTenant
  clusterLocatorMethods:
    - type: "config"
      clusters:
        - url: ${KUBERNETES_URL}
          name: ${NAME}
          authProvider: serviceAccount
          skipTLSVerify: false
          skipMetricsLookup: false
          serviceAccountToken: ${KUBERNETES_SERVICE_ACCOUNT_TOKEN}
          caData: ${KUBERNETES_CERTIFICATE_DATA}

How to add annotation cluster/instructions:

The cluster/instruction annotation is based on a block of text with instructions for raising the cluster, according to its type. It needs to be filled in the cluster's catalog-info.yaml as shown in the example:

apiVersion: veecode.backstage.io/v1alpha1
kind: Cluster
metadata:
  name: "ec2-cluster-2"
  annotations:
    github.com/project-slug: xxxxxxxxxxxxxxxx
    backstage.io/techdocs-ref: dir:.
+    cluster/instructions: |
+      mkdir test
+      echo 'hello world'
spec:
  type: ec2
  lifecycle: development
  owner: "admin"

This way, we'll have a card on the Cluster Overview Page with instructions on how to set up the cluster correctly.

image

How to reuse the resources of the Cluster entity

In the context we envisioned for the project, the Cluster is used to reuse information that will be useful when creating new entities for our catalog.

We have developed customizable components to provide the scaffolder with the possibility of parsing information from the environment key of our Kind.

This is our ResourcePicker, ➡️ here's how to install it.

With it we can approach the reuse of this information when creating entities via a template.

Example:

    - title: Cluster Settings
      properties:
        clusterResource:
          title: Select the Cluster from our catalog
          type: object
          ui:field: ResourcePicker
          ui:options:
            catalogFilter:
              kind: [Cluster]

In this case, we will list all our entities in the catalog that have the Cluster kind, and under the hood we will scan the metadata.enviromnet key of the chosen entity, and thus parse the information as values to serve the skeleton of our template.

example:

...
  steps:
    - id: template
      name: Fetch Skeleton + Template
      action: fetch:template
      input:
        url: ./skeleton      
        values:
          dns: ${{ parameters.clusterResource.type }}

...

ℹ️ Remember to validate that the selected entity has this property, otherwise the values will be empty.

0.2.1

2 days ago

0.2.3

2 days ago

0.2.2

2 days ago

0.1.110

4 days ago

0.1.107

8 days ago

0.1.106

8 days ago

0.1.109

8 days ago

0.1.108

8 days ago

0.1.99

10 days ago

0.1.103

10 days ago

0.1.102

10 days ago

0.1.105

9 days ago

0.1.104

10 days ago

0.1.101

10 days ago

0.1.100

10 days ago

0.1.97

11 days ago

0.1.98

11 days ago

0.1.96

14 days ago

0.1.95

15 days ago

0.1.94

17 days ago

0.1.92

18 days ago

0.1.93

18 days ago

0.1.90

21 days ago

0.1.91

21 days ago

0.1.89

21 days ago

0.1.88

21 days ago

0.1.86

1 month ago

0.1.87

1 month ago

0.1.85

1 month ago

0.1.82

1 month ago

0.1.83

1 month ago

0.1.84

1 month ago

0.1.79

1 month ago

0.1.80

1 month ago

0.1.81

1 month ago

0.1.78

2 months ago

0.1.75

2 months ago

0.1.76

2 months ago

0.1.77

2 months ago

0.1.74

2 months ago

0.1.72

2 months ago

0.1.73

2 months ago

0.1.71

2 months ago

0.1.70

2 months ago

0.1.65

2 months ago

0.1.66

2 months ago

0.1.67

2 months ago

0.1.68

2 months ago

0.1.69

2 months ago

0.1.63

2 months ago

0.1.64

2 months ago

0.1.58

3 months ago

0.1.59

3 months ago

0.1.60

3 months ago

0.1.61

3 months ago

0.1.56

3 months ago

0.1.52

3 months ago

0.1.51

3 months ago

0.1.50

4 months ago

0.1.48

4 months ago

0.1.49

4 months ago

0.1.45

4 months ago

0.1.46

4 months ago

0.1.47

4 months ago

0.1.44

4 months ago

0.1.41

4 months ago

0.1.42

4 months ago

0.1.43

4 months ago

0.1.39

4 months ago

0.1.40

4 months ago

0.1.38

4 months ago

0.1.37

4 months ago