Skip to main content

Kubernetes

Deploy and manage Kubernetes objects against any cluster reachable from the machine running the deployment.

Community Maintained

Version0.0.1
Artifactbr:ghcr.io/anthony-c-martin/bicep-ext-kubernetes:0.0.1
Sourcegithub.com/anthony-c-martin/bicep-ext-kubernetes
Publisheranthony-c-martin
LicenceMIT
CategoryContainers

Installation

Register the extension in bicepconfig.json:

{
"experimentalFeaturesEnabled": {
"localDeploy": true,
"ociEnabled": true
},
"implicitExtensions": [],
"extensions": {
"kubernetes": "br:ghcr.io/anthony-c-martin/bicep-ext-kubernetes:0.0.1"
}
}

Then reference it from your Bicep file:

extension kubernetes

Configuration

Configuration is supplied using extension kubernetes with { ... }.

PropertyTypeAttributesDescription
kubeConfigstringRequired, SensitiveThe Kubernetes configuration file, base-64 encoded.
namespacestringRequiredThe default Kubernetes namespace to deploy resources to.
contextstringThe kubeconfig context to use. If not set, the current context within the kubeconfig file is used.

Connecting to a cluster

The extension needs a kubeconfig file, base-64 encoded, and the namespace to deploy into:

@secure()
param kubeConfig string

extension kubernetes with {
kubeConfig: kubeConfig
namespace: 'default'
}

Encode an existing kubeconfig with:

base64 -i ~/.kube/config
main.bicepparam
using 'main.bicep'

param kubeConfig = readEnvironmentVariable('KUBECONFIG_BASE64')

A kubeconfig can define several clusters. Set context to choose one; when it is omitted the file's current context is used:

extension kubernetes with {
kubeConfig: kubeConfig
namespace: 'default'
context: 'staging-cluster'
}

Example

targetScope = 'local'

@secure()
param kubeConfig string

extension kubernetes with {
kubeConfig: kubeConfig
namespace: 'default'
}

resource deployment 'apps/Deployment@v1' = {
metadata: {
name: 'web'
}
spec: {
replicas: 2
selector: {
matchLabels: {
app: 'web'
}
}
template: {
metadata: {
labels: {
app: 'web'
}
}
spec: {
containers: [
{
name: 'web'
image: 'nginx:1.27'
}
]
}
}
}
}

Notes

  • Resource types follow the Kubernetes group, kind and version convention, such as apps/Deployment@v1 or core/Pod@v1. Alpha and beta API versions are exposed alongside stable ones, for example admissionregistration.k8s.io/ValidatingAdmissionPolicy@v1beta1.
  • Every object requires metadata.name. Set metadata.namespace to override the extension's default namespace for an individual resource.
  • Properties marked read-only, such as apiVersion, kind and status, are populated by the cluster and cannot be set.
  • The machine running the deployment needs network access to the cluster's API server.

Samples

2 example Bicep files are available under Samples.

Resource types

This extension exposes 81 resource types, documented under Reference.

Reference generated from ghcr.io/anthony-c-martin/bicep-ext-kubernetes:0.0.1 on 2026-08-23.