@pulumi/kubernetes
Version:
[](https://github.com/pulumi/pulumi-kubernetes/actions) [](https://slack.pulumi.com) [ || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.StatefulSet = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../../utilities"));
/**
* StatefulSet represents a set of pods with consistent identities. Identities are defined as:
* - Network: A single stable DNS and hostname.
* - Storage: As many VolumeClaims as requested.
*
* The StatefulSet guarantees that a given network identity will always map to the same storage identity.
*
* This resource waits until its status is ready before registering success
* for create/update, and populating output properties from the current state of the resource.
* The following conditions are used to determine whether the resource creation has
* succeeded or failed:
*
* 1. The value of 'spec.replicas' matches '.status.replicas', '.status.currentReplicas',
* and '.status.readyReplicas'.
* 2. The value of '.status.updateRevision' matches '.status.currentRevision'.
*
* If the StatefulSet has not reached a Ready state after 10 minutes, it will
* time out and mark the resource update as Failed. You can override the default timeout value
* by setting the 'customTimeouts' option on the resource.
*
* ## Example Usage
* ### Create a StatefulSet with auto-naming
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as kubernetes from "@pulumi/kubernetes";
*
* const service = new kubernetes.core.v1.Service("service", {
* metadata: {
* labels: {
* app: "nginx",
* },
* },
* spec: {
* clusterIP: "None",
* ports: [{
* name: "web",
* port: 80,
* }],
* selector: {
* app: "nginx",
* },
* },
* });
* const statefulset = new kubernetes.apps.v1.StatefulSet("statefulset", {spec: {
* replicas: 3,
* selector: {
* matchLabels: {
* app: "nginx",
* },
* },
* serviceName: service.metadata.apply(metadata => metadata?.name),
* template: {
* metadata: {
* labels: {
* app: "nginx",
* },
* },
* spec: {
* containers: [{
* image: "nginx:stable-alpine3.17-slim",
* name: "nginx",
* ports: [{
* containerPort: 80,
* name: "web",
* }],
* volumeMounts: [{
* mountPath: "/usr/share/nginx/html",
* name: "www",
* }],
* }],
* terminationGracePeriodSeconds: 10,
* },
* },
* volumeClaimTemplates: [{
* metadata: {
* name: "www",
* },
* spec: {
* accessModes: ["ReadWriteOnce"],
* resources: {
* requests: {
* storage: "1Gi",
* },
* },
* },
* }],
* }});
* ```
* ### Create a StatefulSet with a user-specified name
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as kubernetes from "@pulumi/kubernetes";
*
* const service = new kubernetes.core.v1.Service("service", {
* metadata: {
* labels: {
* app: "nginx",
* },
* name: "nginx",
* },
* spec: {
* clusterIP: "None",
* ports: [{
* name: "web",
* port: 80,
* }],
* selector: {
* app: "nginx",
* },
* },
* });
* const statefulset = new kubernetes.apps.v1.StatefulSet("statefulset", {
* metadata: {
* name: "web",
* },
* spec: {
* replicas: 3,
* selector: {
* matchLabels: {
* app: "nginx",
* },
* },
* serviceName: service.metadata.apply(metadata => metadata?.name),
* template: {
* metadata: {
* labels: {
* app: "nginx",
* },
* },
* spec: {
* containers: [{
* image: "nginx:stable-alpine3.17-slim",
* name: "nginx",
* ports: [{
* containerPort: 80,
* name: "web",
* }],
* volumeMounts: [{
* mountPath: "/usr/share/nginx/html",
* name: "www",
* }],
* }],
* terminationGracePeriodSeconds: 10,
* },
* },
* volumeClaimTemplates: [{
* metadata: {
* name: "www",
* },
* spec: {
* accessModes: ["ReadWriteOnce"],
* resources: {
* requests: {
* storage: "1Gi",
* },
* },
* },
* }],
* },
* });
* ```
*/
class StatefulSet extends pulumi.CustomResource {
/**
* Get an existing StatefulSet resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, opts) {
return new StatefulSet(name, undefined, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'kubernetes:apps/v1:StatefulSet';
/**
* Returns true if the given object is an instance of StatefulSet. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === StatefulSet.__pulumiType;
}
/**
* Create a StatefulSet resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name, args, opts) {
let resourceInputs = {};
opts = opts || {};
if (!opts.id) {
resourceInputs["apiVersion"] = "apps/v1";
resourceInputs["kind"] = "StatefulSet";
resourceInputs["metadata"] = args?.metadata;
resourceInputs["spec"] = args?.spec;
resourceInputs["status"] = undefined /*out*/;
}
else {
resourceInputs["apiVersion"] = undefined /*out*/;
resourceInputs["kind"] = undefined /*out*/;
resourceInputs["metadata"] = undefined /*out*/;
resourceInputs["spec"] = undefined /*out*/;
resourceInputs["status"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const aliasOpts = { aliases: [{ type: "kubernetes:apps/v1beta1:StatefulSet" }, { type: "kubernetes:apps/v1beta2:StatefulSet" }] };
opts = pulumi.mergeOptions(opts, aliasOpts);
super(StatefulSet.__pulumiType, name, resourceInputs, opts);
}
}
exports.StatefulSet = StatefulSet;
//# sourceMappingURL=statefulSet.js.map