Exemple #1
0
import pulumi_digitalocean as do
from pulumi import Config, export, Output, ResourceOptions
from pulumi_kubernetes import Provider
from pulumi_kubernetes.apps.v1 import Deployment
from pulumi_kubernetes.core.v1 import Service

config = Config()
node_count = config.get_float("nodeCount") or 3
app_replica_count = config.get_float("appReplicaCount") or 5
domain_name = config.get("domainName")

cluster = do.KubernetesCluster("do-cluster",
                               region="sfo2",
                               version="latest",
                               node_pool={
                                   "name": "default",
                                   "size": "s-2vcpu-2gb",
                                   "node_count": node_count
                               })

k8s_provider = Provider("do-k8s",
                        kubeconfig=cluster.kube_configs[0]["rawConfig"])

app_labels = {"app": "app-nginx"}
app = Deployment("do-app-dep",
                 spec={
                     'selector': {
                         'matchLabels': app_labels
                     },
                     'replicas': 1,
                     'template': {
Exemple #2
0
from pulumi import Config, export, ResourceOptions, CustomTimeouts
from pulumi_kubernetes import Provider
from pulumi_kubernetes.apps.v1 import Deployment, DeploymentSpecArgs
from pulumi_kubernetes.core.v1 import ContainerArgs, PodSpecArgs, PodTemplateSpecArgs, Service, ServicePortArgs, ServiceSpecArgs
from pulumi_kubernetes.meta.v1 import LabelSelectorArgs, ObjectMetaArgs

config = Config()
node_count = config.get_float("nodeCount") or 3
app_replica_count = config.get_float("appReplicaCount") or 5
domain_name = config.get("domainName")

cluster = do.KubernetesCluster(
    "do-cluster",
    region="nyc3",
    version="latest",
    node_pool=do.KubernetesClusterNodePoolArgs(
        name="default",
        size="s-2vcpu-2gb",
        node_count=node_count
    ))

k8s_provider = Provider("do-k8s", kubeconfig=cluster.kube_configs.apply(lambda c: c[0].raw_config))

app_labels = { "app": "app-nginx" }
app = Deployment(
    "do-app-dep",
    spec=DeploymentSpecArgs(
        selector=LabelSelectorArgs(match_labels=app_labels),
        replicas=1,
        template=PodTemplateSpecArgs(
            metadata=ObjectMetaArgs(labels=app_labels),