blob: 46770f219e68255a502c7dc084458af2f85449b4 [file] [log] [blame]
Lorenz Brun52f7f292020-06-24 16:42:02 +02001// Copyright 2020 The Monogon Project Authors.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17package main
18
19import (
Serge Bazanski075465c2021-11-16 15:38:49 +010020 "context"
Lorenz Brun52f7f292020-06-24 16:42:02 +020021 "log"
Lorenz Brun52f7f292020-06-24 16:42:02 +020022
Serge Bazanski1f8cad72023-03-20 16:58:10 +010023 metroctl "source.monogon.dev/metropolis/cli/metroctl/core"
Serge Bazanski075465c2021-11-16 15:38:49 +010024 clicontext "source.monogon.dev/metropolis/cli/pkg/context"
25 "source.monogon.dev/metropolis/test/launch/cluster"
Lorenz Brun52f7f292020-06-24 16:42:02 +020026)
27
28func main() {
Serge Bazanski075465c2021-11-16 15:38:49 +010029 ctx := clicontext.WithInterrupt(context.Background())
30 cl, err := cluster.LaunchCluster(ctx, cluster.ClusterOptions{
31 NumNodes: 2,
32 })
33 if err != nil {
34 log.Fatalf("LaunchCluster: %v", err)
35 }
Serge Bazanski1f8cad72023-03-20 16:58:10 +010036
37 mpath, err := cluster.MetroctlRunfilePath()
38 if err != nil {
39 log.Fatalf("MetroctlRunfilePath: %v", err)
40 }
41 wpath, err := cl.MakeMetroctlWrapper()
42 if err != nil {
43 log.Fatalf("MakeWrapper: %v", err)
44 }
45
46 apiservers, err := cl.KubernetesControllerNodeAddresses(ctx)
47 if err != nil {
48 log.Fatalf("Could not get Kubernetes controller nodes: %v", err)
49 }
50 if len(apiservers) < 1 {
51 log.Fatalf("Cluster has no Kubernetes controller nodes")
52 }
53
54 configName := "launch-multi2"
55 if err := metroctl.InstallKubeletConfig(mpath, cl.ConnectOptions(), configName, apiservers[0]); err != nil {
56 log.Fatalf("InstallKubeletConfig: %v", err)
57 }
58
Serge Bazanski075465c2021-11-16 15:38:49 +010059 log.Printf("Launch: Cluster running!")
Serge Bazanski1f8cad72023-03-20 16:58:10 +010060 log.Printf(" To access cluster use: metroctl %s", cl.MetroctlFlags())
61 log.Printf(" Or use this handy wrapper: %s", wpath)
62 log.Printf(" To access Kubernetes, use kubectl --context=%s", configName)
Serge Bazanski075465c2021-11-16 15:38:49 +010063
64 <-ctx.Done()
65 cl.Close()
Lorenz Brun52f7f292020-06-24 16:42:02 +020066}