Created
March 10, 2024 05:28
-
-
Save marvin-hansen/f83fc1e3e953f266dbf00323dd9b3e16 to your computer and use it in GitHub Desktop.
Proton Pulumi Deployment Descriptor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pulumi | |
import pulumi_gcp as gcp | |
from pulumi_kubernetes import Provider, apps, core | |
# Define the GCP cluster. | |
cluster = gcp.container.Cluster("time-plus-demo", | |
initial_node_count=3, | |
node_config=gcp.container.ClusterNodeConfigArgs( | |
machine_type="n1-standard-1", | |
# Assuming default disk size and image type. | |
), | |
# Additional cluster configuration options can be provided here if needed. | |
) | |
# Define a kubeconfig to access the cluster. | |
kubeconfig = pulumi.Output.all(cluster.name, cluster.endpoint, cluster.master_auth).apply( | |
lambda args: """apiVersion: v1 | |
clusters: | |
- cluster: | |
certificate-authority-data: {auth} | |
server: https://{endpoint} | |
name: cluster | |
contexts: | |
- context: | |
cluster: cluster | |
user: cluster | |
name: cluster | |
current-context: cluster | |
kind: Config | |
preferences: {{}} | |
users: | |
- name: cluster | |
user: | |
auth-provider: | |
config: | |
cmd-args: config config-helper --format=json | |
cmd-path: gcloud | |
expiry-key: '{{.credential.token_expiry}}' | |
token-key: '{{.credential.access_token}}' | |
name: gcp | |
""".format( | |
auth=args[2]["cluster_ca_certificate"], | |
endpoint=args[1], | |
) | |
) | |
# Create a Kubernetes provider instance using the kubeconfig. | |
k8s_provider = Provider("k8s-provider", kubeconfig=kubeconfig) | |
# Define the deployment for the proton application. | |
app_labels = {"app": "proton"} | |
proton_deployment = apps.v1.Deployment("proton-deployment", | |
spec=apps.v1.DeploymentSpecArgs( | |
selector=core.v1.LabelSelectorArgs(match_labels=app_labels), | |
replicas=1, | |
template=core.v1.PodTemplateSpecArgs( | |
metadata=core.v1.ObjectMetaArgs(labels=app_labels), | |
spec=core.v1.PodSpecArgs( | |
containers=[core.v1.ContainerArgs( | |
name="proton", | |
image="ghcr.io/timeplus-io/proton:latest", | |
)], | |
), | |
), | |
), | |
opts=pulumi.ResourceOptions(provider=k8s_provider) # Specify the provider. | |
) | |
# Export the cluster name and kubeconfig. | |
pulumi.export("cluster_name", cluster.name) | |
pulumi.export("kubeconfig", kubeconfig) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment