https://github.com/kirederik/backstage-k8s-scaffolder-actions
Collection of scaffolder actions for interacting with Kubernetes on Backstage, including apply and delete.
https://github.com/kirederik/backstage-k8s-scaffolder-actions
backstage backstage-scaffolding kubernetes kubernetes-apply
Last synced: about 2 months ago
JSON representation
Collection of scaffolder actions for interacting with Kubernetes on Backstage, including apply and delete.
- Host: GitHub
- URL: https://github.com/kirederik/backstage-k8s-scaffolder-actions
- Owner: kirederik
- License: apache-2.0
- Created: 2023-11-22T18:25:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-15T11:15:26.000Z (about 1 year ago)
- Last Synced: 2024-03-15T12:12:18.266Z (about 1 year ago)
- Topics: backstage, backstage-scaffolding, kubernetes, kubernetes-apply
- Language: TypeScript
- Homepage:
- Size: 194 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Backstage Scaffolder Actions for Kubernetes
This is a Kubernetes actions plugin for the scaffolder-backend in Backstage.
It contains a set of actions to create and manage Kubernetes resources.
# Getting Started
In the root directory of your Backstage project:
```bash
yarn add @devangelista/backstage-scaffolder-kubernetes
```Make sure to add a Kubernetes section to your `app-config.yaml` (check the
Backstage docs)On your `package/backend/src/index.ts` file, add the following:
```ts
backend.add(import("@devangelista/backstage-scaffolder-kubernetes"));
```The scaffolder `kube` actions should now be available to use on your templates. Check the
`/create/actions` endpoint for documentation.# Kubernetes Configuration
This plugin now integrates with Backstage's Kubernetes integration features, allowing you to:
1. Use multiple Kubernetes clusters configured in your Backstage `app-config.yaml`
2. Support various authentication methods (ServiceAccount, Google Cloud, AWS, Azure)
3. Specify which cluster to use for each action## Configuration Example
Here's an example Kubernetes configuration in `app-config.yaml`:
```yaml
kubernetes:
clusterLocatorMethods:
- type: config
clusters:
- name: development
url: https://my-dev-cluster.example.com
authProvider: serviceAccount
serviceAccountToken: ${K8S_DEV_SA_TOKEN}
skipTLSVerify: true
- name: production
url: https://my-prod-cluster.example.com
authProvider: serviceAccount
serviceAccountToken: ${K8S_PROD_SA_TOKEN}
skipTLSVerify: false
caData: ${K8S_PROD_CA_DATA}
```# Usage
You can now use the actions in your templates:
```yaml
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
description: Create a Namespace in Kubernetes
name: create-namespace
title: Create a Namespace
spec:
lifecycle: experimental
owner: user
type: example
parameters:
- properties:
name:
description: The namespace name
title: Name
type: string
ui:autofocus: true
required:
- name
title: Namespace Name
- title: Cluster Name
properties:
cluster:
type: string
enum:
- development
- production
ui:autocomplete:
options:
- development
- production
steps:
- action: kube:apply
id: k-apply
name: Create a Resouce
input:
namespaced: false
clusterName: ${{ parameters.cluster }}
manifest: |
apiVersion: v1
kind: Namespace
metadata:
name: ${{ parameters.name }}
---
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: delete-namespace
description: Delete a Namespace in Kubernetes
title: Delete a Namespace
spec:
lifecycle: experimental
owner: user
type: example
parameters:
- properties:
name:
title: Name
description: The name of the namespace to delete
type: string
ui:autofocus: true
title: Namespace Name
required:
- name
- title: Cluster Name
properties:
cluster:
type: string
enum:
- development
- production
ui:autocomplete:
options:
- development
- production
steps:
- action: kube:delete
id: k-delete
name: Delete
input:
apiVersion: v1
kind: Namespace
clusterName: ${{ parameters.cluster }}
name: ${{ parameters.name }}
```## Authentication Methods
The plugin currently supports the following authentication methods:
1. **Service Account**: Uses a service account token
More methods coming soon!
If no specific cluster is specified, the plugin will use the first cluster defined in the configuration, or fall back to using local kubeconfig.