forked from kubernetes/kops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev-build-scaleway.sh
55 lines (44 loc) · 2.17 KB
/
dev-build-scaleway.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Copyright 2022 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This is a convenience script for developing kOps on Scaleway.
# It builds the code, including nodeup, and uploads to a custom Scaleway object bucket.
# It also sets KOPS_STATE_STORE and KOPS_BASE_URL to project-isolated values.
# To use, source the script. For example `. hack/dev-build-scaleway.sh` (note the initial `.`)
# Can't use set -e in a script we want to source
#set -e
#set -x
# Dev environments typically do not need to test multiple architectures
KOPS_ARCH=amd64
export KOPS_ARCH
# We use the scaleway-cli
# https://github.com/scaleway/scaleway-cli
SCW_DEFAULT_PROJECT_ID=$(scw config get default-project-id)
SCW_DEFAULT_REGION=$(scw config get default-region)
# Build and upload to bucket
UPLOAD_DEST_BUCKET="kops-dev-${SCW_DEFAULT_PROJECT_ID}-${USER}"
export UPLOAD_DEST=s3://${UPLOAD_DEST_BUCKET}
# Scaleway object bucket creation that requires that the aws command line is installed
# https://www.scaleway.com/en/docs/storage/object/api-cli/object-storage-aws-cli/
aws s3 ls "${UPLOAD_DEST}" || aws s3 mb "${UPLOAD_DEST}" || return
make kops-install dev-upload-linux-${KOPS_ARCH} || return
# Set KOPS_BASE_URL
(tools/get_version.sh | grep VERSION | awk '{print $2}') || return
KOPS_VERSION=$(tools/get_version.sh | grep VERSION | awk '{print $2}')
export KOPS_BASE_URL=https://s3.${SCW_DEFAULT_REGION}.scw.cloud/${UPLOAD_DEST_BUCKET}/kops/${KOPS_VERSION}/
# Create the state-store bucket if it doesn't exist
KOPS_STATE_STORE="s3://kops-state-$(scw config get default-project-id)"
export KOPS_STATE_STORE
aws s3 ls "${KOPS_STATE_STORE}" || aws s3 mb "${KOPS_STATE_STORE}" || return
echo "SUCCESS"