UNPKG

@pulumi/kubernetes

Version:

[![Actions Status](https://github.com/pulumi/pulumi-kubernetes/workflows/main/badge.svg)](https://github.com/pulumi/pulumi-kubernetes/actions) [![Slack](http://www.pulumi.com/images/docs/badges/slack.svg)](https://slack.pulumi.com) [![NPM version](https:/

227 lines • 7.74 kB
"use strict"; // *** WARNING: this file was generated by pulumigen. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.StatefulSet = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = 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 }); } /** * 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; /** @internal */ StatefulSet.__pulumiType = 'kubernetes:apps/v1:StatefulSet'; //# sourceMappingURL=statefulSet.js.map