• Stars
    star
    211
  • Rank 186,867 (Top 4 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Kubernetes Operator that automates the deployment of Pulumi Stacks

Pulumi Kubernetes Operator

Pulumi Kubernetes Operator

A Kubernetes operator that provides a CI/CD workflow for Pulumi stacks using Kubernetes primitives. To learn more about the Pulumi Kubernetes Operator visit the Pulumi documentation.

Overview

What is Pulumi?

Pulumi is an open source infrastructure-as-code tool for creating, deploying, and managing cloud infrastructure in the programming language of your choice. If you are new to Pulumi, please consider visiting the getting started first to familiarize yourself with Pulumi and concepts such as Pulumi stacks and backends.

When To Use the Pulumi Kubernetes Operator?

The Pulumi Kubernetes Operator enables Kubernetes users to create a Pulumi Stack as a first-class Kubernetes API resource, and use the StackController to drive the updates. It allows users to adopt a GitOps workflow for managing their cloud infrastructure using Pulumi. This infrastructure includes Kubernetes resources in addition to over 60 cloud providers including AWS, Azure, and Google Cloud. The operator provides an alternative to Pulumi's other CI/CD integrations such as Github Actions, Gitlab CI, Jenkins etc. See the full list of Pulumi's CI/CD integrations here. Since the Pulumi Kubernetes Operator can be deployed on any Kubernetes cluster, it provides turnkey GitOps functionality for Pulumi users running in self-hosted or restricted settings. The Kubernetes Operator pattern, lends itself nicely to automation scenarios by driving to the specified state and automatically retrying if transient failures are encountered.

Prerequisites

The following steps should be completed before starting on Pulumi:

Install Pulumi CLI

Follow the Pulumi installation instructions for your OS. For instance, on Mac OS, the easiest way to install Pulumi CLI is from Homebrew:

$ brew install pulumi

Login to Your Chosen State Backend

The operator stores additional metadata about provisioned resources. By default, Pulumi (and the Pulumi Kubernetes Operator) uses the Pulumi managed SaaS backend to store this state and manage concurrency. However, in addition to the managed backend, Pulumi also readily integrates with a variety of state backends, like S3, Azure Blob Storage, Google Cloud Storage, etc. See here for a detailed discussion on choosing a state backend.

Login to Pulumi using your chosen state backend. For simplicity we will only cover the Pulumi managed SaaS state backend and AWS S3 here:

Pulumi SaaS Backend
$ pulumi login

This will display a prompt that asks for you to provide an access token or automatically request an access token:

Manage your Pulumi stacks by logging in.
Run `pulumi login --help` for alternative login options.
Enter your access token from https://app.pulumi.com/account/tokens
    or hit <ENTER> to log in using your browser                   :

In order to configure the Pulumi Kubernetes Operator to use Stacks with state stored on the SaaS backend, you will also need to manually generate access tokens. This can be done by accessing the Access Tokens page. Setting the environment variable PULUMI_ACCESS_TOKEN to the manually generated token will obviate the need for a pulumi login.

At this point your pulumi CLI is configured to work with the Pulumi SaaS backend.

AWS S3 Backend
  1. First, you will need to create an S3 bucket manually, either through the AWS CLI or the AWS Console.
  2. If you have already configured the AWS CLI to use credential files, single sign-on etc., Pulumi will automatically respect and use these settings. Alternatively you can set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables to the access key and secret access key respectively.
  3. To use the AWS S3 backend, pass the s3://<bucket-name> as your <backend-url> to pulumi login, i.e.:
    $ pulumi login s3://<bucket-name>
    
    For additional options, refer to the Pulumi documentation.
  4. You will need the AWS credentials when configuring Stack CRs for stacks you wish to be backed by the S3 bucket.
  5. Lastly you will need to create an AWS Key Management Service (KMS) key. This key will be used by Pulumi to encrypt secret configuration values or outputs associated with stacks. Pulumi ensures all secrets are stored encrypted in transit and at rest. By default, the SaaS backend creates per-stack encryption keys to do this, however, Pulumi can leverage KMS as one of several supported encryption providers instead, thus allowing users to self-manage their encryption keys.

Deploy the Operator

Deploy the operator to a Kubernetes cluster.

You can use an existing cluster, or get started by creating a new managed Kubernetes cluster. We will assume that your target Kubernetes cluster is already created and you have configured kubectl to point to it. Note that Pulumi doesn't actually use kubectl but for convenience can use the same mechanism to authenticate against clusters.

Using kubectl

First, download the latest release source code tar ball and expand it locally.

Deploy the CustomResourceDefinitions (CRDs) for the operator.

kubectl apply -f deploy/crds/

Deploy the API resources for the operator.

kubectl apply -f deploy/yaml

This will deploy the operator to the default namespace (which depends on your configuration, and is usually "default"). To deploy to a different namespace:

kubectl apply -n <namespace> -f deploy/yaml

You can deploy to several namespaces by repeating the above command.

Using Pulumi

First, make sure you have reviewed and performed the tasks identified in the prerequisite section.

We will create a Pulumi project to deploy the operator by using a template, then customize it if necessary, then use pulumi up to run it. There is a choice of template, related to the programming language and environment you wish to use:

  • deploy/deploy-operator-cs (.NET)
  • deploy/deploy-operator-go (Go)
  • deploy/deploy-operator-py (Python)
  • deploy/deploy-operator-ts (TypeScript/NodeJS)

Pick one of those, then create a new project in a fresh directory:

TEMPLATE=deploy/deploy-operator-ts # for example
mkdir deploy-operator
cd deploy-operator
pulumi new https://github.com/pulumi/pulumi-kubernetes-operator/$TEMPLATE
# If using the S3 state backend, you may wish to set the secrets provider here
pulumi stack change-secrets-provider "awskms:///arn:aws:kms:...?region=<region>"

You can then set the namespace, or namespaces, in which to deploy the operator:

pulumi config set namespace ns1
# OR deploy to multiple namespaces
pulumi set config --path namespaces[0] ns1
pulumi set config --path namespaces[1] ns2

And finally, run the program:

pulumi up

Upgrading the operator

For patch and minor version releases, you can just bump the version in your stack config and rerun pulumi up. For example, if the new version is v1.10.2, you would do this:

pulumi config set operator-version v1.10.2
pulumi up

Create Pulumi Stack CustomResources

The following are examples to create Pulumi Stacks in Kubernetes that are managed and run by the operator.

Using kubectl

Check out Create Pulumi Stacks using kubectl for YAML examples.

Using Pulumi

Check out Create Pulumi Stacks using Pulumi for Typescript, Python, Go, and .NET examples.

Extended Examples

If you'd like to use your own Pulumi Stack, ensure that you have an existing Pulumi program in a git repo, and update the CR with:

  • An existing github project and/or commit,
  • A Pulumi stack name that exists and will be selected, or a new stack that will be created and selected.
  • A Kubernetes Secret for your Pulumi API accessToken,
  • A Kubernetes Secret for other sensitive settings like cloud provider credentials, and
  • Environment variables and stack config as needed.

Stack CR Documentation

Detailed documentation on Stack Custom Resource is available here.

Prometheus Metrics Integration

Details on metrics emitted by the Pulumi Kubernetes Operator as instructions on getting them to flow to Prometheus are available here.

Development

Check out docs/build.md for more details on building and working with the operator locally.

More Repositories

1

pulumi

Pulumi - Infrastructure as Code in any programming language πŸš€
Go
21,443
star
2

kubespy

Tools for observing Kubernetes resources in real time, powered by Pulumi.
Go
2,689
star
3

examples

Infrastructure, containers, and serverless apps to AWS, Azure, GCP, and Kubernetes... all deployed with Pulumi
TypeScript
2,074
star
4

pulumi-aws

An Amazon Web Services (AWS) Pulumi resource package, providing multi-language access to AWS
Java
358
star
5

pulumi-kubernetes

A Pulumi resource provider for Kubernetes to manage API resources and workloads in running clusters
Java
358
star
6

tf2pulumi

A tool to convert Terraform projects to Pulumi
Go
291
star
7

actions

Deploy continuously to your cloud of choice, using your favorite language, Pulumi, and GitHub!
TypeScript
237
star
8

pulumi-ai

TypeScript
225
star
9

esc

Pulumi ESC (Environments, Secrets, and Configuration) for cloud applications and infrastructure.
Go
219
star
10

automation-api-examples

Examples for the Pulumi Automation API https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/auto?tab=doc
Go
191
star
11

pulumi-awsx

AWS infrastructure best practices in component form!
TypeScript
178
star
12

pulumi-eks

A Pulumi component for easily creating and managing an Amazon EKS Cluster
Java
154
star
13

pulumi-terraform-bridge

A library allowing providers built with the Terraform Plugin SDK to be bridged into Pulumi.
Go
145
star
14

pulumi-gcp

A Google Cloud Platform (GCP) Pulumi resource package, providing multi-language access to GCP
Java
145
star
15

pulumi-kubernetesx

Kubernetes for Everyone
TypeScript
129
star
16

docs

All things Pulumi docs!
HTML
127
star
17

pulumi-azure

A Microsoft Azure Pulumi resource package, providing multi-language access to Azure
Java
123
star
18

pulumi-azure-native

Azure Native Provider
114
star
19

pulumi-cloud

A highly productive multi-cloud framework for containers, serverless, and data
TypeScript
113
star
20

pulumi-terraform

A resource package that allows Pulumi programs to use Terraform state
Go
106
star
21

kube2pulumi

Upgrade your Kubernetes YAML to a modern language
Go
105
star
22

infrastructure-as-code-workshop

Infrastructure as Code Workshop
C#
92
star
23

pulumi-aws-native

AWS Native Provider for Pulumi
Go
89
star
24

workshops

A definitive place to store all the Pulumi workshops
TypeScript
88
star
25

kubernetes-guides

Crosswalk Playbooks and Code for Teams to Manage Kubernetes in Production
TypeScript
80
star
26

crd2pulumi

Generate typed CustomResources from a Kubernetes CustomResourceDefinition
Go
74
star
27

pulumi-java

Java support for Pulumi
Java
69
star
28

pulumi-command

Java
64
star
29

pulumi-google-native

Python
64
star
30

pulumi-cloudflare

Pulumi's Cloudflare package, providing multi-language infrastructure as code for Cloudflare
Java
63
star
31

pulumi-cdk

Pulumi/CDK Interop Library
TypeScript
61
star
32

pulumi-docker

A Docker Pulumi resource package, providing multi-language access to Docker resources and building images.
Java
60
star
33

templates

Templates used by `pulumi new`
Go
58
star
34

pulumi-tf-provider-boilerplate

Boilerplate code for Terraform provider-backed Pulumi packages
Go
57
star
35

pulumi-alicloud

An AliCloud Pulumi resource package, providing multi-language access to AliCloud
Go
48
star
36

pulumi-vsphere

A Pulumi resource package for VMWare VSphere, providing multi-language access to vCenter Server and ESXi
Java
46
star
37

setup-pulumi

GitHub Action to install the Pulumi CLI
TypeScript
45
star
38

pulumi-provider-boilerplate

Boilerplate showing how to create a native Pulumi provider
Python
42
star
39

pulumi-openstack

An OpenStack Pulumi resource package, providing multi-language access to OpenStack
Java
39
star
40

pulumi-github

A Pulumi package to facilitate interacting with GitHub
Java
39
star
41

pulumi-yaml

YAML language provider for Pulumi
Go
38
star
42

pulumi-go-provider

A framework for building Go Providers for Pulumi
Go
33
star
43

pulumi-hugo

A Hugo module containing content and layouts used on pulumi.com, including hand-authored docs, the Pulumi blog, and Learn Pulumi.
CSS
32
star
44

pulumi-hcloud

A Hetzner Cloud Pulumi resource package, providing multi-language access to Hetzner Cloud
Java
32
star
45

pulumi-azure-nextgen

Next generation Microsoft Azure provider for Pulumi, providing multi-language access to Azure
29
star
46

pulumi-random

A Pulumi provider that safely enables randomness for resources
Java
29
star
47

pulumi-oci

An Oracle Cloud (OCI) Pulumi resource package, providing multi-language access to OCI
Go
28
star
48

pulumi-policy

Pulumi's Policy as Code SDK, CrossGuard. Define infrastructure checks in code to enforce security, compliance, cost, and other practices, enforced at deployment time.
TypeScript
28
star
49

registry

The global index of everything you can do with Pulumi.
HTML
27
star
50

pulumi-dotnet

.NET support for Pulumi
C#
27
star
51

pulumi-self-hosted-installers

Repository for getting started with self-hosted Pulumi Service.
TypeScript
27
star
52

pulumi-keycloak

A KeyCloak Pulumi resource package, providing multi-language access to KeyCloak
Java
27
star
53

pulumi-postgresql

A Postgresql Pulumi resource package
Go
27
star
54

pulumi-vault

A Vault Pulumi resource package, providing multi-language access to HashiCorp Vault
Go
25
star
55

pulumictl

A swiss army knife for Pulumi development
Go
24
star
56

pulumi-policy-aws

A policy pack of rules to enforce AWS best practices for security, reliability, cost, and more!
TypeScript
24
star
57

pulumi-libvirt

Java
23
star
58

pulumi-linode

Linode resource provider for Pulumi
Java
23
star
59

pulumi-lsp

A LSP server for Pulumi YAML
Go
22
star
60

pulumi-component-provider-ts-boilerplate

Go
22
star
61

pulumi-auth0

An auth0Pulumi resource package, providing multi-language access to Auth0
Go
22
star
62

pulumi-az-pipelines-task

Azure Pipelines task extension for running Pulumi apps.
TypeScript
20
star
63

circleci

CircleCI Orbs for CI/CD using Pulumi.
JavaScript
19
star
64

pulumi-component-provider-py-boilerplate

Demonstrates building a multi-lang Pulumi component provider in Python
Python
19
star
65

pulumi-gitlab

A GitLab Pulumi resource package, providing multi-language access to GitLab
Java
18
star
66

pulumi-azuredevops

An AzureDevOps Pulumi resource package, providing multi-language access to AzureDevOps
Go
17
star
67

halloumi

Go
17
star
68

actions-example-gke-rails

Deploys a Dockerized Rails app to Kubernetes on Google, using GitHub Actions and Pulumi
HTML
17
star
69

pulumi-backstage-plugin

Pulumi plugin for Backstage
TypeScript
17
star
70

compliance-policies

A library of policies for Pulumi's Policy as Code
TypeScript
16
star
71

pulumi-datadog

An Datadog Pulumi resource package, providing multi-language access to Datadog
Go
16
star
72

pulumitv

Projects and examples related to Pulumi TV
TypeScript
15
star
73

pulumi-aws-serverless

Easy serverless programming for AWS
TypeScript
15
star
74

pulumi-azuread

A Microsoft Azure Active Directory (Azure AD) Pulumi resource package, providing multi-language access to Azure AD
Java
15
star
75

pulumi-snowflake

Go
15
star
76

pulumi-databricks

Go
15
star
77

pulumi-docker-containers

Definitions for official Pulumi Docker images.
Dockerfile
14
star
78

pulumi-component-provider-go-boilerplate

Go
14
star
79

pulumi-tailscale

Makefile
14
star
80

pulumi-kubernetes-cert-manager

A Pulumi Kubernetes CertManager component
Java
14
star
81

pulumi-pulumiservice

Go
13
star
82

eks-blueprint

Go
13
star
83

pulumi-yandex

Python
13
star
84

pulumi-mongodbatlas

A MongoDB Atlas Pulumi resource package, providing multi-language access to MongoDB Atlas
Java
12
star
85

actions-pulumify

Pulumify - A GitHub Action to continuously deploy static website previews
Python
12
star
86

devcontainer

Pulumi build and development artifacts
Makefile
12
star
87

pulumi-aiven

An Aiven Pulumi resource package, providing multi-language access to Aiven
Go
12
star
88

pulumi-kafka

A Kafka Pulumi resource package, providing multi-language access to Kafka
Java
12
star
89

pulumi-aws-static-website

TypeScript
11
star
90

pulumi-policy-opa

A bridge enabling Pulumi CrossGuard to run OPA rules
Go
11
star
91

pulumi-cloud-requests

Welcome to the public issue tracker for Pulumi Cloud (app.pulumi.com)! Feature requests and bug reports welcome!
11
star
92

pulumi-aws-apigateway

TypeScript
11
star
93

pulumi-import-aws-account-scraper

Example of using boto3 to generate JSON for pulumi import
Python
11
star
94

pulumi-query-kubernetes

A relational TypeScript SDK for querying Kubernetes resources in any cluster, either on-prem or in any cloud.
TypeScript
11
star
95

pulumi-kubernetes-ingress-nginx

A Pulumi NGINX Ingress Controller component
Python
11
star
96

pulumi-newrelic

An New Relic Pulumi resource package, providing multi-language access to New Relic
Java
10
star
97

pulumi-nomad

Go
10
star
98

tf12-vs-pulumi

A collection of HCL2 examples, rewritten to Pulumi
10
star
99

introduction-to-pulumi

An interactive workshop to get started with Pulumi
Dockerfile
10
star
100

travisqueue

Sequence Travis builds per branch
Go
9
star