10.3. Red Hat Developer Hub での Kubernetes カスタムアクションを使用したテンプレートの作成
Template オブジェクトを YAML ファイルとして定義することでテンプレートを作成できます。
Template オブジェクトは、テンプレートとそのメタデータを記述します。また、必要な入力変数と、スキャフォールディングサービスによって実行されるアクションのリストも含まれています。
+
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: create-kubernetes-namespace
title: Create a kubernetes namespace
description: Create a kubernetes namespace
spec:
type: service
parameters:
- title: Information
required: [namespace, token]
properties:
namespace:
title: Namespace name
type: string
description: Name of the namespace to be created
clusterRef:
title: Cluster reference
type: string
description: Cluster resource entity reference from the catalog
ui:field: EntityPicker
ui:options:
catalogFilter:
kind: Resource
url:
title: Url
type: string
description: Url of the kubernetes API, will be used if clusterRef is not provided
token:
title: Token
type: string
ui:field: Secret
description: Bearer token to authenticate with
skipTLSVerify:
title: Skip TLS verification
type: boolean
description: Skip TLS certificate verification, not recommended to use in production environment, default to false
caData:
title: CA data
type: string
ui:field: Secret
description: Certificate Authority base64 encoded certificate
labels:
title: Labels
type: string
description: Labels to be applied to the namespace
ui:widget: textarea
ui:options:
rows: 3
ui:help: 'Hint: Separate multiple labels with a semicolon!'
ui:placeholder: 'kubernetes.io/type=namespace; app.io/managed-by=org'
steps:
- id: create-kubernetes-namespace
name: Create kubernetes namespace
action: kubernetes:create-namespace
input:
namespace: ${{ parameters.namespace }}
clusterRef: ${{ parameters.clusterRef }}
url: ${{ parameters.url }}
token: ${{ secrets.token }}
skipTLSVerify: ${{ parameters.skipTLSVerify }}
caData: ${{ secrets.caData }}
labels: ${{ parameters.labels }}
10.3.1. Red Hat Developer Hub でサポートされている Kubernetes カスタムアクション リンクのコピーリンクがクリップボードにコピーされました!
Red Hat Developer Hub では、scaffolder テンプレートでカスタム Kubernetes アクションを使用できます。
カスタムの Kubernetes scaffolder アクション
- アクション: kubernetes:create-namespace
- Developer Hub に Kubernetes クラスターの namespace を作成します。
| パラメーター名 | 型 | 要件 | 説明 | 例 |
|---|---|---|---|---|
|
|
| 必須 | Kubernetes namespace の名前 |
|
|
|
|
| カタログからのクラスターリソースエンティティーの参照 |
|
|
|
|
| Kubernetes クラスターの API URL | |
|
|
| 必須 | 認証に使用する Kubernetes API ベアラートークン | |
|
|
| 任意 | true の場合、証明書の検証がスキップされます。 | false |
|
|
| 任意 | Base64 でエンコードされた証明書データ | |
|
|
| 任意 | namespace に適用されるラベル | app.io/type=ns; app.io/managed-by=org; |