Repository navigation
Expand file tree
/
Copy path__main__.py
More file actions
57 lines (51 loc) · 1.5 KB
/
Copy path__main__.py
File metadata and controls
57 lines (51 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
Example DevZero infrastructure using the Python SDK.
Creates:
- A Cluster named "prod-cluster-python"
- A WorkloadPolicy with CPU vertical scaling enabled
- A WorkloadPolicyTarget linking the policy to the cluster for Deployments
"""
import pulumi
from pulumi_devzero.resources import (
Cluster,
ClusterArgs,
WorkloadPolicy,
WorkloadPolicyArgs,
WorkloadPolicyTarget,
WorkloadPolicyTargetArgs,
VerticalScalingArgsArgs,
)
# Create a cluster
cluster = Cluster(
"prod-cluster-python",
args=ClusterArgs(
name="prod-cluster-python",
),
)
# Create a workload policy with CPU vertical scaling enabled
policy = WorkloadPolicy(
"cpu-scaling-policy",
args=WorkloadPolicyArgs(
name="cpu-scaling-policy-py-1",
description="Workload policy with CPU vertical scaling for production cluster",
cpu_vertical_scaling=VerticalScalingArgsArgs(
enabled=True,
),
),
)
# Create a workload policy target linking the policy to the cluster for Deployments
target = WorkloadPolicyTarget(
"prod-cluster-python-deployments-target",
args=WorkloadPolicyTargetArgs(
name="prod-cluster-python-deployments-target",
policy_id=policy.id,
cluster_ids=[cluster.id],
kind_filter=["Deployment"],
enabled=True,
),
)
# Exports
pulumi.export("cluster_id", cluster.id)
pulumi.export("cluster_token", pulumi.Output.secret(cluster.token))
pulumi.export("policy_id", policy.id)
pulumi.export("target_id", target.id)