What is @pulumi/kubernetes?
@pulumi/kubernetes is an npm package that allows you to manage Kubernetes resources using Pulumi, a modern infrastructure as code platform. With this package, you can define, deploy, and manage Kubernetes applications and infrastructure using familiar programming languages like JavaScript, TypeScript, and Python.
What are @pulumi/kubernetes's main functionalities?
Creating Kubernetes Resources
This feature allows you to create Kubernetes resources such as Deployments, Services, and ConfigMaps. The code sample demonstrates how to create a simple Nginx deployment with two replicas.
const pulumi = require('@pulumi/pulumi');
const k8s = require('@pulumi/kubernetes');
const appLabels = { app: 'nginx' };
const deployment = new k8s.apps.v1.Deployment('nginx-deployment', {
spec: {
selector: { matchLabels: appLabels },
replicas: 2,
template: {
metadata: { labels: appLabels },
spec: { containers: [{ name: 'nginx', image: 'nginx' }] }
}
}
});
exports.deploymentName = deployment.metadata.name;
Managing Kubernetes Configurations
This feature allows you to manage Kubernetes configurations such as ConfigMaps and Secrets. The code sample demonstrates how to create a ConfigMap with a key-value pair.
const pulumi = require('@pulumi/pulumi');
const k8s = require('@pulumi/kubernetes');
const configMap = new k8s.core.v1.ConfigMap('my-config', {
metadata: { name: 'my-config' },
data: { 'key': 'value' }
});
exports.configMapName = configMap.metadata.name;
Deploying Helm Charts
This feature allows you to deploy applications using Helm charts. The code sample demonstrates how to deploy an Nginx Helm chart from the Bitnami repository.
const pulumi = require('@pulumi/pulumi');
const k8s = require('@pulumi/kubernetes');
const nginx = new k8s.helm.v3.Chart('nginx', {
chart: 'nginx',
version: '1.0.0',
fetchOpts: { repo: 'https://charts.bitnami.com/bitnami' }
});
exports.nginxServiceName = nginx.getResource('v1/Service', 'nginx').metadata.name;
Other packages similar to @pulumi/kubernetes
kubernetes
The 'kubernetes' npm package is a client library for interacting with the Kubernetes API. It allows you to manage Kubernetes resources programmatically. Unlike @pulumi/kubernetes, it does not provide infrastructure as code capabilities and is more focused on direct API interactions.
kubernetes-client
The 'kubernetes-client' npm package is another client library for the Kubernetes API. It provides a higher-level abstraction compared to the 'kubernetes' package and includes features like easy resource creation and management. However, it lacks the infrastructure as code features provided by @pulumi/kubernetes.
k8s
The 'k8s' npm package is a lightweight client for the Kubernetes API. It is designed for simplicity and ease of use, making it suitable for small scripts and automation tasks. It does not offer the comprehensive infrastructure as code capabilities of @pulumi/kubernetes.
Kubernetes Resource Provider
:warning: Pulumi is in private beta. This package may not work unless you are already participating.
Please visit pulumi.com to register for access.
The Kubernetes provider for Pulumi lets you use Kubernetes resources in your cloud programs.
This package is meant for use with the Pulumi CLI. Please visit docs.pulumi.com for
installation instructions.