MCPcopy
hub / github.com/modelcontextprotocol/registry / CreateCluster

Method CreateCluster

deploy/pkg/providers/gcp/provider.go:184–334  ·  view source on GitHub ↗

CreateCluster creates a Google Kubernetes Engine cluster

(ctx *pulumi.Context, environment string)

Source from the content-addressed store, hash-verified

182
183// CreateCluster creates a Google Kubernetes Engine cluster
184func (p *Provider) CreateCluster(ctx *pulumi.Context, environment string) (*providers.ProviderInfo, error) {
185 // Get configuration
186 gcpConf := config.New(ctx, "gcp")
187
188 // Get project ID from config
189 projectID := gcpConf.Get("project")
190 if projectID == "" {
191 return nil, fmt.Errorf("GCP project ID not configured. Set gcp:project")
192 }
193
194 // Get region from config or use default
195 region := gcpConf.Get("region")
196 if region == "" {
197 region = "us-central1"
198 }
199
200 // Create GCP provider with explicit credentials if configured
201 gcpProvider, err := createGCPProvider(ctx, "gcp-explicit")
202 if err != nil {
203 return nil, err
204 }
205
206 // Create GKE cluster
207 clusterName := fmt.Sprintf("mcp-registry-%s", environment)
208
209 // Use a specific zone instead of region for zonal cluster
210 zone := fmt.Sprintf("%s-b", region)
211
212 // Configure the GKE cluster
213 clusterArgs := &container.ClusterArgs{
214 Name: pulumi.String(clusterName),
215 Location: pulumi.String(zone),
216 Project: pulumi.String(projectID),
217 Description: pulumi.String(fmt.Sprintf("MCP Registry %s GKE Cluster", environment)),
218
219 // Initial node count (will be managed by node pool)
220 InitialNodeCount: pulumi.Int(1),
221
222 // Remove default node pool after cluster creation
223 RemoveDefaultNodePool: pulumi.Bool(true),
224
225 AddonsConfig: &container.ClusterAddonsConfigArgs{
226 // Disable as we use ingress-nginx
227 HttpLoadBalancing: &container.ClusterAddonsConfigHttpLoadBalancingArgs{
228 Disabled: pulumi.Bool(true),
229 },
230 },
231 }
232
233 // Add provider if we have explicit credentials
234 clusterOpts := []pulumi.ResourceOption{}
235 if gcpProvider != nil {
236 clusterOpts = append(clusterOpts, pulumi.Provider(gcpProvider))
237 }
238
239 cluster, err := container.NewCluster(ctx, clusterName, clusterArgs, clusterOpts...)
240 if err != nil {
241 return nil, fmt.Errorf("failed to create GKE cluster: %w", err)

Callers

nothing calls this directly

Calls 3

createGCPProviderFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected