Skip to content

Commit aecd7e0

Browse files
authored
Merge pull request #121 from FabianKramm/main
fix: fixed arm build issue & --upgrade flag & v1.22
2 parents b9faac1 + a85e329 commit aecd7e0

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Build the manager binary
2-
FROM golang:1.15 as builder
2+
FROM golang:1.16 as builder
33

44
WORKDIR /vcluster
5-
ARG TARGETOS=linux
6-
ARG TARGETARCH=amd64
5+
ARG TARGETOS
6+
ARG TARGETARCH
77

88
# Install kubectl for development
99
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl && chmod +x ./kubectl && mv ./kubectl /usr/local/bin/kubectl

cmd/vclusterctl/cmd/create.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import (
2323
)
2424

2525
var VersionMap = map[string]string{
26-
"1.21": "rancher/k3s:v1.21.3-k3s1",
26+
"1.22": "rancher/k3s:v1.22.1-rc1-k3s1",
27+
"1.21": "rancher/k3s:v1.21.4-k3s1",
2728
"1.20": "rancher/k3s:v1.20.9-k3s1",
2829
"1.19": "rancher/k3s:v1.19.13-k3s1",
2930
"1.18": "rancher/k3s:v1.18.20-k3s1",
@@ -67,6 +68,7 @@ type CreateCmd struct {
6768
CreateClusterRole bool
6869
Expose bool
6970
Connect bool
71+
Upgrade bool
7072

7173
log log.Logger
7274
}
@@ -100,7 +102,7 @@ vcluster create test --namespace test
100102
},
101103
}
102104

103-
cobraCmd.Flags().StringVar(&cmd.ChartVersion, "chart-version", upgrade.GetVersion(), "The virtual cluster chart version to use")
105+
cobraCmd.Flags().StringVar(&cmd.ChartVersion, "chart-version", upgrade.GetVersion(), "The virtual cluster chart version to use (e.g. v0.4.0)")
104106
cobraCmd.Flags().StringVar(&cmd.ChartName, "chart-name", "vcluster", "The virtual cluster chart name to use")
105107
cobraCmd.Flags().StringVar(&cmd.ChartRepo, "chart-repo", "https://charts.loft.sh", "The virtual cluster chart repo to use")
106108
cobraCmd.Flags().StringVar(&cmd.ReleaseValues, "release-values", "", "Path where to load the virtual cluster helm release values from")
@@ -111,6 +113,7 @@ vcluster create test --namespace test
111113
cobraCmd.Flags().BoolVar(&cmd.CreateClusterRole, "create-cluster-role", false, "If true a cluster role will be created to access nodes, storageclasses and priorityclasses")
112114
cobraCmd.Flags().BoolVar(&cmd.Expose, "expose", false, "If true will create a load balancer service to expose the vcluster endpoint")
113115
cobraCmd.Flags().BoolVar(&cmd.Connect, "connect", false, "If true will run vcluster connect directly after the vcluster was created")
116+
cobraCmd.Flags().BoolVar(&cmd.Upgrade, "upgrade", true, "If true will try to upgrade the vcluster instead of failing if it already exists")
114117
return cobraCmd
115118
}
116119

@@ -197,6 +200,14 @@ func (cmd *CreateCmd) Run(cobraCmd *cobra.Command, args []string) error {
197200
values = string(byteValues)
198201
}
199202

203+
// check if vcluster already exists
204+
if cmd.Upgrade == false {
205+
_, err = client.AppsV1().StatefulSets(namespace).Get(context.TODO(), args[0], metav1.GetOptions{})
206+
if err == nil {
207+
return fmt.Errorf("vcluster %s already exists in namespace %s", args[0], namespace)
208+
}
209+
}
210+
200211
// we have to upgrade / install the chart
201212
err = helm.NewClient(&rawConfig, cmd.log).Upgrade(args[0], namespace, helm.UpgradeOptions{
202213
Chart: cmd.ChartName,
@@ -244,10 +255,10 @@ func (cmd *CreateCmd) getDefaultReleaseValues(client kubernetes.Interface, names
244255
var ok bool
245256
image, ok = VersionMap[serverVersionString]
246257
if !ok {
247-
if serverMinorInt > 21 {
248-
log.Infof("officially unsupported host server version %s, will fallback to virtual cluster version v1.21", serverVersionString)
249-
image = VersionMap["1.21"]
250-
serverVersionString = "1.21"
258+
if serverMinorInt > 22 {
259+
log.Infof("officially unsupported host server version %s, will fallback to virtual cluster version v1.22", serverVersionString)
260+
image = VersionMap["1.22"]
261+
serverVersionString = "1.22"
251262
} else {
252263
log.Infof("officially unsupported host server version %s, will fallback to virtual cluster version v1.16", serverVersionString)
253264
image = VersionMap["1.16"]

devspace.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ images:
1313
image: ${SYNCER_IMAGE}
1414
rebuildStrategy: ignoreContextChanges
1515
build:
16-
docker:
16+
buildKit:
1717
skipPush: true
1818
options:
1919
target: builder
@@ -65,8 +65,9 @@ profiles:
6565
patches:
6666
- op: remove
6767
path: images.vcluster.rebuildStrategy
68-
- op: remove
69-
path: images.vcluster.build
68+
- op: replace
69+
path: images.vcluster.build.buildKit
70+
value: {}
7071
- op: replace
7172
path: deployments[0].helm.values.syncer
7273
value:

0 commit comments

Comments
 (0)