https://pulumi.com logo
#general
Title
# general
r

red-apple-53102

08/30/2023, 2:08 PM
hello all i’ve written python pulumi code that creates k8s cluster on aws and now i want to deploy some pods and services on that cluster using pulumi python, how can i set to deplo k8s resources on previous created cluster?
l

limited-rainbow-51650

08/30/2023, 2:10 PM
Hello @red-apple-53102, you can create a kubernetes provider object in your code and pass the kubeconfig output to it that you retrieve from the cluster object you created.
Once you have that, pass this provider as one of the resource options to any of the Kubernetes resources you create.
r

red-apple-53102

08/30/2023, 2:17 PM
thank you for your help! can you just tell me, this is the only way to do it?
l

limited-rainbow-51650

08/30/2023, 2:17 PM
Yes, this is the only way: via an explicit provider object in your code. This is needed to get the resource dependencies correct for the Pulumi engine.
Keep in mind that the actual resource creation is not happing in your Pulumi program (Python, TS, ...). Your program creates the expected resource graph which is sent locally via a GRPC connection to the Pulumi engine (part of the CLI). The engine calculates the diff based on the state file and applies the needed changes.
r

red-apple-53102

08/30/2023, 2:34 PM
thank you
i need help if you can provide, this is my python code for cluster
# Get some values from the Pulumi configuration (or use defaults) config = pulumi.Config() min_cluster_size = config.get_float(“minClusterSize”, 3) max_cluster_size = config.get_float(“maxClusterSize”, 6) desired_cluster_size = config.get_float(“desiredClusterSize”, 3) eks_node_instance_type = config.get(“eksNodeInstanceType”, “t3.medium”) vpc_network_cidr = config.get(“vpcNetworkCidr”, “10.0.0.0/16”) # Create a VPC for the EKS cluster eks_vpc = awsx.ec2.Vpc(“eks-vpc”, enable_dns_hostnames=True, cidr_block=vpc_network_cidr) # Create the EKS cluster eks_cluster = eks.Cluster(“eks-cluster”, # Put the cluster in the new VPC created earlier vpc_id=eks_vpc.vpc_id, # Public subnets will be used for load balancers public_subnet_ids=eks_vpc.public_subnet_ids, # Private subnets will be used for cluster nodes private_subnet_ids=eks_vpc.private_subnet_ids, # Change configuration values to change any of the following settings instance_type=eks_node_instance_type, desired_capacity=desired_cluster_size, min_size=min_cluster_size, max_size=max_cluster_size, # Do not give worker nodes a public IP address node_associate_public_ip_address=False, # Uncomment the next two lines for private cluster (VPN access required) # endpoint_private_access=true, # endpoint_public_access=false )
can you help me with writing provider block?
d

dry-keyboard-94795

08/30/2023, 3:29 PM
Worth reading through the EKS guide: https://www.pulumi.com/docs/clouds/aws/guides/eks/