Skip to content

Commit b8ddcd9

Browse files
committed
chore(builder): change storage to minio
1 parent 482e9bc commit b8ddcd9

10 files changed

Lines changed: 58 additions & 62 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ rootfs/usr/bin/
55
coverage.txt
66
testdata/hooks/pre-receive
77
.idea/
8-
8+
.vscode/

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ We welcome your input! If you have feedback, please [submit an issue][issues]. I
1919
The builder is primarily a git server that responds to `git push`es by executing either the `git-receive-pack` or `git-upload-pack` hook. After it executes one of those hooks, it takes the following high level steps in order:
2020

2121
1. Calls `git archive` to produce a tarball (i.e. a `.tar.gz` file) on the local file system
22-
2. Saves the tarball to centralized object storage according to the following rules:
23-
- If the `BUILDER_STORAGE` environment variable is other than `minio`, attempts to create the appropriate storage driver and saves using this driver.
24-
- Otherwise, if `BUILDER_STORAGE` is `minio` and the `DRYCC_MINIO_ENDPOINT` environment variables exist (these are standard [Kubernetes service discovery environment variables](http://kubernetes.io/docs/user-guide/services/#environment-variables)), saves to the [S3 API][s3-api-ref] compatible server at `$DRYCC_MINIO_ENDPOINT`
25-
3. Starts a new [Kubernetes Pod](http://kubernetes.io/docs/user-guide/pods/) to build the code, according to the following rules:
22+
2. Starts a new [Kubernetes Pod](http://kubernetes.io/docs/user-guide/pods/) to build the code, according to the following rules:
2623
- If there is a `Dockerfile`, build the container with imagebuilder
2724
- Otherwise, use imagebuilder to build CNCF native buildpack
2825
- You can use `DRYCC_STACK` specifies the build type. Currently, it supports two types: `buildpack` and `container`

charts/builder/templates/_helpers.tpl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,30 @@ env:
2525
secretKeyRef:
2626
name: builder-key-auth
2727
key: builder-key
28-
- name: "DRYCC_MINIO_LOOKUP"
28+
- name: "DRYCC_STORAGE_LOOKUP"
2929
valueFrom:
3030
secretKeyRef:
31-
name: minio-creds
31+
name: storage-creds
3232
key: lookup
33-
- name: "DRYCC_MINIO_BUCKET"
33+
- name: "DRYCC_STORAGE_BUCKET"
3434
valueFrom:
3535
secretKeyRef:
36-
name: minio-creds
36+
name: storage-creds
3737
key: builder-bucket
38-
- name: "DRYCC_MINIO_ENDPOINT"
38+
- name: "DRYCC_STORAGE_ENDPOINT"
3939
valueFrom:
4040
secretKeyRef:
41-
name: minio-creds
41+
name: storage-creds
4242
key: endpoint
43-
- name: "DRYCC_MINIO_ACCESSKEY"
43+
- name: "DRYCC_STORAGE_ACCESSKEY"
4444
valueFrom:
4545
secretKeyRef:
46-
name: minio-creds
46+
name: storage-creds
4747
key: accesskey
48-
- name: "DRYCC_MINIO_SECRETKEY"
48+
- name: "DRYCC_STORAGE_SECRETKEY"
4949
valueFrom:
5050
secretKeyRef:
51-
name: minio-creds
51+
name: storage-creds
5252
key: secretkey
5353
- name: "DRYCC_REGISTRY_LOCATION"
5454
value: "{{ .Values.global.registryLocation }}"

charts/builder/templates/builder-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ spec:
3434
- netcat
3535
- -v
3636
- -u
37-
- $(DRYCC_MINIO_ENDPOINT)
37+
- $(DRYCC_STORAGE_ENDPOINT)
3838
{{- include "builder.envs" . | indent 8 }}
3939
containers:
4040
- name: drycc-builder

pkg/cleaner/cleaner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func dirHasGitSuffix(dir string) bool {
8888
return strings.HasSuffix(dir, dotGitSuffix)
8989
}
9090

91-
func deleteFromMinio(app string, storageDriver storagedriver.StorageDriver) error {
91+
func deleteFromStorage(app string, storageDriver storagedriver.StorageDriver) error {
9292

9393
// delete all files matching app
9494
objs, err := storageDriver.List(context.Background(), "home")
@@ -138,7 +138,7 @@ func Run(gitHome string, nsLister k8s.NamespaceLister, fs sys.FS, pollSleepDurat
138138
if err := fs.RemoveAll(dirToDelete); err != nil {
139139
log.Err("Cleaner error removing local files for deleted app %s (%s)", dirToDelete, err)
140140
}
141-
if err := deleteFromMinio(appToDelete, storageDriver); err != nil {
141+
if err := deleteFromStorage(appToDelete, storageDriver); err != nil {
142142
log.Err("Cleaner error removing object store files for deleted app %s (%s)", appToDelete, err)
143143
}
144144
}

pkg/conf/config.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111
)
1212

1313
const (
14-
minioLookupEnvVar = "DRYCC_MINIO_LOOKUP"
15-
minioBucketEnvVar = "DRYCC_MINIO_BUCKET"
16-
minioEndpointEnvVar = "DRYCC_MINIO_ENDPOINT"
17-
minioAccesskeyEnvVar = "DRYCC_MINIO_ACCESSKEY"
18-
minioSecretkeyEnvVar = "DRYCC_MINIO_SECRETKEY"
14+
storageLookupEnvVar = "DRYCC_STORAGE_LOOKUP"
15+
storageBucketEnvVar = "DRYCC_STORAGE_BUCKET"
16+
storageEndpointEnvVar = "DRYCC_STORAGE_ENDPOINT"
17+
storageAccesskeyEnvVar = "DRYCC_STORAGE_ACCESSKEY"
18+
storageSecretkeyEnvVar = "DRYCC_STORAGE_SECRETKEY"
1919
)
2020

2121
// BuilderKeyLocation holds the path of the builder key secret.
@@ -38,7 +38,7 @@ func GetBuilderKey() (string, error) {
3838
func GetStorageParams(env sys.Env) (Parameters, error) {
3939
params := make(map[string]interface{})
4040

41-
mEndpoint := env.Get(minioEndpointEnvVar)
41+
mEndpoint := env.Get(storageEndpointEnvVar)
4242
params["regionendpoint"] = mEndpoint
4343
region := "us-east-1" //region is required in distribution
4444
if endpointURL, err := url.Parse(mEndpoint); err == nil {
@@ -48,10 +48,10 @@ func GetStorageParams(env sys.Env) (Parameters, error) {
4848
}
4949
params["region"] = region
5050

51-
params["accesskey"] = env.Get(minioAccesskeyEnvVar)
52-
params["secretkey"] = env.Get(minioSecretkeyEnvVar)
53-
params["bucket"] = env.Get(minioBucketEnvVar)
54-
if env.Get(minioLookupEnvVar) == "path" {
51+
params["accesskey"] = env.Get(storageAccesskeyEnvVar)
52+
params["secretkey"] = env.Get(storageSecretkeyEnvVar)
53+
params["bucket"] = env.Get(storageBucketEnvVar)
54+
if env.Get(storageLookupEnvVar) == "path" {
5555
params["forcepathstyle"] = "true"
5656
}
5757

pkg/conf/config_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ func TestGetStorageParams(t *testing.T) {
1414

1515
env := sys.NewFakeEnv()
1616
env.Envs = map[string]string{
17-
"BUILDER_STORAGE": "minio",
18-
"DRYCC_MINIO_LOOKUP": "path",
19-
"DRYCC_MINIO_BUCKET": "builder",
20-
"DRYCC_MINIO_ENDPOINT": "http://localhost:8088",
21-
"DRYCC_MINIO_ACCESSKEY": "admin",
22-
"DRYCC_MINIO_SECRETKEY": "adminpass",
17+
"DRYCC_STORAGE_LOOKUP": "path",
18+
"DRYCC_STORAGE_BUCKET": "builder",
19+
"DRYCC_STORAGE_ENDPOINT": "http://localhost:8088",
20+
"DRYCC_STORAGE_ACCESSKEY": "admin",
21+
"DRYCC_STORAGE_SECRETKEY": "adminpass",
2322
}
2423
params, err := GetStorageParams(env)
2524
if err != nil {

pkg/gitreceive/imagebuilder.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99

1010
var (
1111
requiredEnvNames = []string{
12-
"DRYCC_MINIO_LOOKUP",
13-
"DRYCC_MINIO_BUCKET",
14-
"DRYCC_MINIO_ENDPOINT",
12+
"DRYCC_STORAGE_LOOKUP",
13+
"DRYCC_STORAGE_BUCKET",
14+
"DRYCC_STORAGE_ENDPOINT",
1515
"DRYCC_REGISTRY_HOST",
1616
}
1717
)
@@ -37,7 +37,7 @@ func checkImagebuilderRequiredEnv(imagebuilderEnv map[string]string) error {
3737
}
3838

3939
func getImagebuilderEnv(image *string, config *Config, env sys.Env) (map[string]string, error) {
40-
imagebuilderEnv := env.Environ([]string{"DRYCC_REGISTRY_", "DRYCC_MINIO_"})
40+
imagebuilderEnv := env.Environ([]string{"DRYCC_REGISTRY_", "DRYCC_STORAGE_"})
4141
if err := checkImagebuilderRequiredEnv(imagebuilderEnv); err != nil {
4242
return nil, err
4343
}

pkg/gitreceive/imagebuilder_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ func TestGetImagebuilderEnvOffclusterErr(t *testing.T) {
1515
}
1616
env := sys.NewFakeEnv()
1717
env.Envs = map[string]string{
18-
"DRYCC_MINIO_LOOKUP": "path",
19-
"DRYCC_MINIO_BUCKET": "builder",
20-
"DRYCC_MINIO_ENDPOINT": "drycc-minio.drycc.svc.cluster.local",
18+
"DRYCC_STORAGE_LOOKUP": "path",
19+
"DRYCC_STORAGE_BUCKET": "builder",
20+
"DRYCC_STORAGE_ENDPOINT": "drycc-storage.drycc.svc.cluster.local",
2121
"DRYCC_REGISTRY_LOCATION": "off-cluster",
2222
}
2323
_, err := getImagebuilderEnv(&image, config, env)
@@ -30,17 +30,17 @@ func TestGetImagebuilderEnvOffclusterErr(t *testing.T) {
3030
func TestGetImagebuilderEnvOffclusterSuccess(t *testing.T) {
3131
env := sys.NewFakeEnv()
3232
env.Envs = map[string]string{
33-
"DRYCC_MINIO_LOOKUP": "path",
34-
"DRYCC_MINIO_BUCKET": "builder",
35-
"DRYCC_MINIO_ENDPOINT": "drycc-minio.drycc.svc.cluster.local",
33+
"DRYCC_STORAGE_LOOKUP": "path",
34+
"DRYCC_STORAGE_BUCKET": "builder",
35+
"DRYCC_STORAGE_ENDPOINT": "drycc-storage.drycc.svc.cluster.local",
3636
"DRYCC_REGISTRY_HOST": "quay.io",
3737
"DRYCC_REGISTRY_ORGANIZATION": "kmala",
3838
"DRYCC_REGISTRY_LOCATION": "off-cluster",
3939
}
4040
expectedData := map[string]string{
41-
"DRYCC_MINIO_LOOKUP": "path",
42-
"DRYCC_MINIO_BUCKET": "builder",
43-
"DRYCC_MINIO_ENDPOINT": "drycc-minio.drycc.svc.cluster.local",
41+
"DRYCC_STORAGE_LOOKUP": "path",
42+
"DRYCC_STORAGE_BUCKET": "builder",
43+
"DRYCC_STORAGE_ENDPOINT": "drycc-storage.drycc.svc.cluster.local",
4444
"DRYCC_REGISTRY_LOCATION": "off-cluster",
4545
"DRYCC_REGISTRY_HOST": "quay.io",
4646
"DRYCC_REGISTRY_ORGANIZATION": "kmala",
@@ -61,17 +61,17 @@ func TestGetImagebuilderEnvOffclusterSuccess(t *testing.T) {
6161
func TestGetImagebuilderEnvOnclusterSuccess(t *testing.T) {
6262
env := sys.NewFakeEnv()
6363
env.Envs = map[string]string{
64-
"DRYCC_MINIO_LOOKUP": "path",
65-
"DRYCC_MINIO_BUCKET": "builder",
66-
"DRYCC_MINIO_ENDPOINT": "drycc-minio.drycc.svc.cluster.local",
64+
"DRYCC_STORAGE_LOOKUP": "path",
65+
"DRYCC_STORAGE_BUCKET": "builder",
66+
"DRYCC_STORAGE_ENDPOINT": "drycc-storage.drycc.svc.cluster.local",
6767
"DRYCC_REGISTRY_HOST": "drycc-registry.drycc.svc.cluster.local",
6868
"DRYCC_REGISTRY_PROXY_HOST": "127.0.0.1:8000",
6969
"DRYCC_REGISTRY_LOCATION": "on-cluster",
7070
}
7171
expectedData := map[string]string{
72-
"DRYCC_MINIO_LOOKUP": "path",
73-
"DRYCC_MINIO_BUCKET": "builder",
74-
"DRYCC_MINIO_ENDPOINT": "drycc-minio.drycc.svc.cluster.local",
72+
"DRYCC_STORAGE_LOOKUP": "path",
73+
"DRYCC_STORAGE_BUCKET": "builder",
74+
"DRYCC_STORAGE_ENDPOINT": "drycc-storage.drycc.svc.cluster.local",
7575
"DRYCC_REGISTRY_HOST": "drycc-registry.drycc.svc.cluster.local",
7676
"DRYCC_REGISTRY_LOCATION": "on-cluster",
7777
"DRYCC_REGISTRY_PROXY_HOST": "127.0.0.1:8000",

rootfs/bin/create_bucket

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
set -e
44

5-
mc config host add minio \
6-
"${DRYCC_MINIO_ENDPOINT}" \
7-
"${DRYCC_MINIO_ACCESSKEY}" \
8-
"${DRYCC_MINIO_SECRETKEY}" \
9-
--lookup "${DRYCC_MINIO_LOOKUP}" \
5+
mc config host add storage \
6+
"${DRYCC_STORAGE_ENDPOINT}" \
7+
"${DRYCC_STORAGE_ACCESSKEY}" \
8+
"${DRYCC_STORAGE_SECRETKEY}" \
9+
--lookup "${DRYCC_STORAGE_LOOKUP}" \
1010
--api s3v4
1111

1212
has_bucket(){
13-
mc ls minio -json|jq -r '.key'|grep -w "${DRYCC_MINIO_BUCKET}"
13+
mc ls storage -json|jq -r '.key'|grep -w "${DRYCC_STORAGE_BUCKET}"
1414
}
1515

1616
if [ -z "$(has_bucket)" ] ;then
17-
mc mb minio/"${DRYCC_MINIO_BUCKET}"
17+
mc mb storage/"${DRYCC_STORAGE_BUCKET}"
1818
if [ -z "$(has_bucket)" ] ;then
19-
echo "create bucket ${DRYCC_MINIO_BUCKET} error"
19+
echo "create bucket ${DRYCC_STORAGE_BUCKET} error"
2020
exit 1
2121
fi
2222
fi
23-
echo "create bucket ${DRYCC_MINIO_BUCKET} success"
23+
echo "create bucket ${DRYCC_STORAGE_BUCKET} success"

0 commit comments

Comments
 (0)