-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTiltfile
120 lines (98 loc) · 2.44 KB
/
Tiltfile
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# -*- mode: Python -*-
def indent(text, amount, ch=' '):
padding = amount * ch
output = ''
for line in text.splitlines(True):
output += padding + line
return output
# set defaults
settings = {
"minio": True,
"blob_bucket": "kubeadm-backup-dev",
# S3 Configuration
# "s3": {
# "endpoint": "", # https://docs.aws.amazon.com/general/latest/gr/s3.html
# "access_key": "",
# "secret_key": ""
# },
# GCS Configuration
# "gcs": {
# "service_account_file": ""
# }
}
# global settings
settings.update(read_json(
"tilt-settings.json",
default={},
))
blob_config = None
# if minio is set deploy minio use it's s3 creds
if settings['minio']:
blob_config = '''
type: S3
config:
endpoint: "minio:9000"
insecure: true
bucket: "kubeadm-backup-dev"
access_key: "minio"
secret_key: "minio123"
'''
# deploy minio
k8s_yaml(kustomize('kustomize/minio'))
# port forward minio
k8s_resource('minio', port_forwards="9000")
else:
# s3 is given so lets use that
if 's3' in settings:
blob_config = '''
type: S3
config:
endpoint: "%(endpoint)s"
bucket: "%(blob_bucket)s"
access_key: "%(access_key)s"
secret_key: "%(secret_key)s"
''' % {'blob_bucket': settings['blob_bucket'], 'endpoint': '', 'access_key': '', 'secret_key': ''}
# gcs is given so lets use that
elif 'gcs' in settings:
blob_config = '''
type: GCS
config:
bucket: "%(blob_bucket)s"
service_account: %(gcs_service_account)s
''' % {'blob_bucket': settings['blob_bucket'], 'gcs_service_account': ''}
# no blob storage creds given
else:
fail('Valid blob credentials must be given when minio is false')
if blob_config == None:
fail('blob config file is None for some reason')
blob_config = blob_config.strip()
blob_secret = '''
apiVersion: v1
kind: Secret
metadata:
name: kubeadm-backup-blob-config
stringData:
config.yaml: |-
%(blob_config)s
''' % {'blob_config': indent(blob_config, 8)}
local_resource(
'kubeadm-backup-binary',
cmd='make build-amd64',
deps=[
'cmd',
'pkg'
],
)
custom_build(
'kubeadm-backup',
'docker build -t $EXPECTED_REF .',
deps=[
'bin/kubeadm-backup-linux-amd64',
'Dockerfile'
],
)
# apply blob secret
k8s_yaml(blob(blob_secret))
k8s_resource('kubeadm-backup', resource_deps=['minio'])
# apply kustomize
k8s_yaml(kustomize('kustomize/tilt'))