Kubernetes · Arazzo Workflow

Kubernetes Provision a ClusterRole If Missing

Version 1.0.0

Check whether a ClusterRole already exists and create it only when it does not.

1 workflow 1 source API 1 provider
View Spec View on GitHub AutomationCloud-NativeCNCFContainersDeploymentOpen-SourceOrchestrationScalingArazzoWorkflows

Provider

kubernetes

Workflows

provision-cluster-role
Create a ClusterRole with the supplied policy rules unless it already exists.
Looks for an existing ClusterRole by name and branches: when it is already present the flow ends without writing, and when it is absent the role is created with the supplied rules.
2 steps inputs: clusterRoleName, labelSelector, labels, rules outputs: clusterRoleName, createdRules, existingClusterRoles
1
findClusterRole
List ClusterRoles so the flow can tell an existing role from a missing one by name, rather than provoking a 409 conflict on create.
2
createClusterRole
Create the ClusterRole with the supplied policy rules. ClusterRoles are cluster-scoped and take effect once bound via a ClusterRoleBinding.

Source API Descriptions

Arazzo Workflow Specification

Raw ↑
arazzo: 1.0.1
info:
  title: Kubernetes Provision a ClusterRole If Missing
  summary: Check whether a ClusterRole already exists and create it only when it does not.
  description: >-
    The idempotent RBAC bootstrap an installer runs before granting an operator
    or controller its permissions. The workflow lists ClusterRoles, branches on
    whether the target role is already present, and creates it with explicit
    policy rules only when it is missing — so re-running the install does not
    fail on a 409 conflict. Every step spells out its request inline so the flow
    can be read and executed without opening the underlying OpenAPI
    description.
  version: 1.0.0
sourceDescriptions:
- name: rbacApi
  url: ../openapi/kubernetes-rbac-api-openapi.yml
  type: openapi
workflows:
- workflowId: provision-cluster-role
  summary: Create a ClusterRole with the supplied policy rules unless it already exists.
  description: >-
    Looks for an existing ClusterRole by name and branches: when it is already
    present the flow ends without writing, and when it is absent the role is
    created with the supplied rules.
  inputs:
    type: object
    required:
    - clusterRoleName
    - rules
    properties:
      clusterRoleName:
        type: string
        description: Name of the ClusterRole to provision.
      rules:
        type: array
        description: >-
          Policy rules granting verbs on resources within API groups. Each rule
          carries verbs, apiGroups, and resources arrays.
        items:
          type: object
      labels:
        type: object
        description: Labels to apply to the ClusterRole, such as an installer or owner tag.
      labelSelector:
        type: string
        description: >-
          Optional label selector narrowing the listing to an installer's own
          roles. ClusterRole listing supports label selection only, so the
          branch below matches the target by name within the returned set.
  steps:
  - stepId: findClusterRole
    description: >-
      List ClusterRoles so the flow can tell an existing role from a missing
      one by name, rather than provoking a 409 conflict on create.
    operationId: listClusterRoles
    parameters:
    - name: labelSelector
      in: query
      value: $inputs.labelSelector
    - name: limit
      in: query
      value: 500
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      clusterRoles: $response.body#/items
    onSuccess:
    - name: clusterRoleMissing
      type: goto
      stepId: createClusterRole
      criteria:
      - context: $response.body
        condition: $.items[?(@.metadata.name == '$inputs.clusterRoleName')].length == 0
        type: jsonpath
    - name: clusterRoleExists
      type: end
      criteria:
      - context: $response.body
        condition: $.items[?(@.metadata.name == '$inputs.clusterRoleName')].length > 0
        type: jsonpath
  - stepId: createClusterRole
    description: >-
      Create the ClusterRole with the supplied policy rules. ClusterRoles are
      cluster-scoped and take effect once bound via a ClusterRoleBinding.
    operationId: createClusterRole
    requestBody:
      contentType: application/json
      payload:
        apiVersion: rbac.authorization.k8s.io/v1
        kind: ClusterRole
        metadata:
          name: $inputs.clusterRoleName
          labels: $inputs.labels
        rules: $inputs.rules
    successCriteria:
    - condition: $statusCode == 201
    outputs:
      clusterRoleName: $response.body#/metadata/name
      clusterRoleUid: $response.body#/metadata/uid
      createdRules: $response.body#/rules
  outputs:
    existingClusterRoles: $steps.findClusterRole.outputs.clusterRoles
    clusterRoleName: $steps.createClusterRole.outputs.clusterRoleName
    createdRules: $steps.createClusterRole.outputs.createdRules

Work with this as data

Every workflow here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for arazzo workflows

4 MCP tools reach this
  • find_arazzoBrowse and filter every workflow in the catalog.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This workflow
curl "https://apis.io/api/v1/arazzo/kubernetes-provision-cluster-role-workflow"
All arazzo workflows
curl "https://apis.io/api/v1/arazzo?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.