Skip to content

Commit 25bdde1

Browse files
authored
Merge pull request #107 from codefresh-io/dind-storage
Dind storage
2 parents c98f975 + 77228b5 commit 25bdde1

20 files changed

+958
-177
lines changed

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
| --skip-runtime-installation | boolean | Set flag if you already have a configured runtime-environment, add --runtime-environment flag with name |
4848
| --storage-class | string | Set a name of your custom storage class, note: this will not install volume provisioning components |
4949
| --tolerations | string | The kubernetes tolerations as JSON string to be used by venona resources (default is no tolerations). If prefixed with "@", loads from a file: @/tmp/tolerations.json |
50+
| --set-value | stringArray | Set values for templates, example: --set-value Storage.LocalVolumeParentDir=/mnt/disk/ssd0/codefresh-volumes |
5051
| --venona-version | string | Version of venona to install (default is the latest) |
5152

5253
#### Install on cluster version < 1.10
@@ -72,6 +73,85 @@ rules:
7273
* Bind your user with cluster-admin kubernetes clusterrole
7374
> `kubectl create clusterrolebinding NAME --clusterrole cluster-admin --user YOUR_USER`
7475

76+
#### Pipeline Storage with docker cache support
77+
78+
##### **GKE LocalSSD**
79+
*Prerequisite:* [GKE custer with local SSD](https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/local-ssd)
80+
81+
*Install venona for using GKE Local SSD:*
82+
```
83+
venonactl install [options] --set-value=Storage.LocalVolumeParentDir=/mnt/disks/ssd0/codefresh-volumes \
84+
--build-node-selector=cloud.google.com/gke-local-ssd=true
85+
```
86+
87+
##### **GCE Disks**
88+
*Prerequisite:* volume provisioner (dind-volume-provisioner) should have permissions to create/delete/get of google disks
89+
There are 3 options to provide cloud credentials on GCE:
90+
* run venona dind-volume-provisioniner on node with iam role which is allowed to create/delete/get of google disks
91+
* create Google Service Account with ComputeEngine.StorageAdmin, download its key and pass it to venona installed with `--set-file=Storage.GooogleServiceAccount=/path/to/google-service-account.json`
92+
* use [Google Workload Identity](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity) to assign iam role to `volume-provisioner-venona` service account
93+
94+
*Note*: Builds will be running in single availability zone, so you must to specify AvailabilityZone params
95+
96+
97+
*Install venona for using GKE Disks:*
98+
```
99+
venonactl install [options] --set-value=Storage.Backend=gcedisk \
100+
--set-value=Storage.AvailabilityZone=us-central1-a \
101+
--build-node-selector=failure-domain.beta.kubernetes.io/zone=us-central1-a \
102+
[--set-file=Storage.GoogleServiceAccount=/path/to/google-service-account.json]
103+
```
104+
105+
##### **Amazon EBS**
106+
107+
*Prerequisite:* volume provisioner (dind-volume-provisioner) should have permissions to create/delete/get of aws ebs
108+
Minimal iam policy for dind-volume-provisioner:
109+
```json
110+
{
111+
"Version": "2012-10-17",
112+
"Statement": [
113+
{
114+
"Effect": "Allow",
115+
"Action": [
116+
"ec2:AttachVolume",
117+
"ec2:CreateSnapshot",
118+
"ec2:CreateTags",
119+
"ec2:CreateVolume",
120+
"ec2:DeleteSnapshot",
121+
"ec2:DeleteTags",
122+
"ec2:DeleteVolume",
123+
"ec2:DescribeInstances",
124+
"ec2:DescribeSnapshots",
125+
"ec2:DescribeTags",
126+
"ec2:DescribeVolumes",
127+
"ec2:DetachVolume"
128+
],
129+
"Resource": "*"
130+
}
131+
]
132+
}
133+
```
134+
135+
There are 3 options to provide cloud credentials on AWS:
136+
* run venona dind-volume-provisioniner on node with the iam role - use `--kube-node-selector=` option
137+
* create AWS IAM User, assign it the permissions above and suppy aws credentials to venona installer `--set-value=Storage.AwsAccessKeyId=ABCDF --set-value=Storage.AwsSecretAccessKey=ZYXWV`
138+
139+
* use [Aws Identity for Service Account](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html) to assign iam role to `volume-provisioner-venona` service account
140+
141+
*Notes*:
142+
- Builds will be running in single availability zone, so you must specify AvailabilityZone parameter `--set-value=Storage.AvailabilityZone=<aws-az>` and build-node-selector `--build-node-selector=failure-domain.beta.kubernetes.io/zone=<aws-az>` in case of multizone cluster
143+
144+
- We support both [in-tree ebs](https://kubernetes.io/docs/concepts/storage/volumes/#awselasticblockstore) (`--set-value=Storage.Backend=ebs`) volumes and ebs-csi(https://github.com/kubernetes-sigs/aws-ebs-csi-driver) (`--set-value=Storage.Backend=ebs-csi`)
145+
146+
*Install Command to run pipelines on ebs volumes*
147+
```
148+
venonactl install [options] --set-value=Storage.Backend=ebs \
149+
--set-value=Storage.AvailabilityZone=us-east-1d \
150+
--build-node-selector=failure-domain.beta.kubernetes.io/zone=us-east-1d \
151+
[--kube-node-selector=kubernetes.io/role=master] \
152+
[--set-value=Storage.AwsAccessKeyId=ABCDF --set-value=Storage.AwsSecretAccessKey=ZYXWV]
153+
```
154+
75155
#### Kubernetes RBAC
76156
Installation of Venona on Kubernetes cluster installing 2 groups of objects,
77157
Each one has own RBAC needs and therefore, created roles(and cluster-roles)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "venona",
3-
"version": "0.30.5",
3+
"version": "0.31.0",
44
"description": "Codefresh agent to run on Codefresh's runtime environment and execute pipeline",
55
"main": "index.js",
66
"scripts": {

venonactl/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.30.5
1+
0.31.0

venonactl/cmd/install.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/codefresh-io/venona/venonactl/pkg/plugins"
3232
"github.com/spf13/cobra"
3333
"github.com/spf13/viper"
34+
"helm.sh/helm/v3/pkg/strvals"
3435
k8sApi "k8s.io/api/core/v1"
3536
)
3637

@@ -60,6 +61,8 @@ var installCmdOptions struct {
6061
buildNodeSelector string
6162
buildAnnotations []string
6263
tolerations string
64+
templateValues []string
65+
templateFileValues []string
6366
}
6467

6568
// installCmd represents the install command
@@ -197,6 +200,27 @@ var installCmd = &cobra.Command{
197200
}
198201

199202
values := s.BuildValues()
203+
204+
// from https://github.com/helm/helm/blob/ec1d1a3d3eb672232f896f9d3b3d0797e4f519e3/pkg/cli/values/options.go#L41
205+
base := map[string]interface{}{}
206+
for _, value := range installCmdOptions.templateValues {
207+
if err := strvals.ParseInto(value, base); err != nil {
208+
dieOnError(fmt.Errorf("Cannot parse option --set-value %s", value))
209+
}
210+
}
211+
212+
for _, value := range installCmdOptions.templateFileValues {
213+
reader := func(rs []rune) (interface{}, error) {
214+
bytes, err := ioutil.ReadFile(string(rs))
215+
return string(bytes), err
216+
}
217+
if err := strvals.ParseIntoFile(value, base, reader); err != nil {
218+
dieOnError(fmt.Errorf("Cannot parse option --set-file %s", value))
219+
}
220+
}
221+
222+
values = mergeMaps(values, base)
223+
200224
for _, p := range builder.Get() {
201225
values, err = p.Install(builderInstallOpt, values)
202226
if err != nil {
@@ -207,6 +231,25 @@ var installCmd = &cobra.Command{
207231
},
208232
}
209233

234+
func mergeMaps(a, b map[string]interface{}) map[string]interface{} {
235+
out := make(map[string]interface{}, len(a))
236+
for k, v := range a {
237+
out[k] = v
238+
}
239+
for k, v := range b {
240+
if v, ok := v.(map[string]interface{}); ok {
241+
if bv, ok := out[k]; ok {
242+
if bv, ok := bv.(map[string]interface{}); ok {
243+
out[k] = mergeMaps(bv, v)
244+
continue
245+
}
246+
}
247+
}
248+
out[k] = v
249+
}
250+
return out
251+
}
252+
210253
func init() {
211254
rootCmd.AddCommand(installCmd)
212255

@@ -231,6 +274,9 @@ func init() {
231274
installCmd.Flags().BoolVar(&installCmdOptions.setDefaultRuntime, "set-default", false, "Mark the install runtime-environment as default one after installation")
232275
installCmd.Flags().BoolVar(&installCmdOptions.kubernetesRunnerType, "kubernetes-runner-type", false, "Set the runner type to kubernetes (alpha feature)")
233276

277+
installCmd.Flags().StringArrayVar(&installCmdOptions.templateValues, "set-value", []string{}, "Set values for templates, example: --set-value LocalVolumesDir=/mnt/disks/ssd0/codefresh-volumes")
278+
installCmd.Flags().StringArrayVar(&installCmdOptions.templateFileValues, "set-file", []string{}, "Set values for templates from file, example: --set-value Storage.GoogleServiceAccount=/path/to/service-account.json")
279+
234280
}
235281

236282
type nodeSelector map[string]string

venonactl/go.mod

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,29 @@
11
module github.com/codefresh-io/venona/venonactl
22

3+
go 1.13
4+
35
require (
4-
contrib.go.opencensus.io/exporter/ocagent v0.4.3 // indirect
5-
github.com/Azure/go-autorest v11.4.0+incompatible // indirect
6-
github.com/Masterminds/goutils v1.1.0 // indirect
6+
github.com/Azure/go-autorest/autorest v0.10.0 // indirect
77
github.com/Masterminds/semver v1.5.0 // indirect
88
github.com/Masterminds/sprig v2.22.0+incompatible
9-
github.com/codefresh-io/go-sdk v0.17.0
9+
github.com/codefresh-io/go-sdk v0.18.0
1010
github.com/dustin/go-humanize v1.0.0
11-
github.com/google/go-github/v21 v21.0.0
12-
github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367 // indirect
13-
github.com/google/uuid v1.1.1 // indirect
14-
github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d // indirect
15-
github.com/gophercloud/gophercloud v0.0.0-20190206021053-df38e1611dbe // indirect
16-
github.com/gregjones/httpcache v0.0.0-20170728041850-787624de3eb7 // indirect
17-
github.com/hashicorp/go-version v1.1.0
11+
github.com/google/go-github/v21 v21.0.1
12+
github.com/gophercloud/gophercloud v0.8.0 // indirect
13+
github.com/hashicorp/go-version v1.2.0
1814
github.com/huandu/xstrings v1.3.0 // indirect
19-
github.com/imdario/mergo v0.3.5 // indirect
20-
github.com/inconshreveable/log15 v0.0.0-20180818164646-67afb5ed74ec
21-
github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be // indirect
22-
github.com/mattn/go-colorable v0.1.0 // indirect
23-
github.com/mattn/go-isatty v0.0.4 // indirect
24-
github.com/mitchellh/copystructure v1.0.0 // indirect
25-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
26-
github.com/modern-go/reflect2 v1.0.1 // indirect
15+
github.com/imdario/mergo v0.3.8 // indirect
16+
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1
17+
github.com/mattn/go-colorable v0.1.6 // indirect
2718
github.com/olekukonko/tablewriter v0.0.4
28-
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
29-
github.com/spf13/cobra v0.0.5
30-
github.com/spf13/viper v1.6.1
31-
go.opencensus.io v0.19.0 // indirect
32-
google.golang.org/appengine v1.4.0 // indirect
33-
gopkg.in/inf.v0 v0.9.0 // indirect
34-
gopkg.in/yaml.v2 v2.2.7
35-
k8s.io/api v0.0.0-20181221193117-173ce66c1e39
36-
k8s.io/apimachinery v0.0.0-20181127025237-2b1284ed4c93
37-
k8s.io/client-go v10.0.0+incompatible
38-
k8s.io/klog v0.0.0-20181108234604-8139d8cb77af // indirect
39-
sigs.k8s.io/yaml v1.1.0 // indirect
19+
github.com/spf13/cobra v0.0.6
20+
github.com/spf13/viper v1.6.2
21+
gopkg.in/yaml.v2 v2.2.8
22+
helm.sh/helm/v3 v3.1.1
23+
k8s.io/api v0.17.3
24+
k8s.io/apimachinery v0.17.3
25+
k8s.io/client-go v0.17.3
26+
k8s.io/utils v0.0.0-20200229041039-0a110f9eb7ab // indirect
4027
)
4128

42-
replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20181218151757-9b75e4fe745a
43-
44-
go 1.13
29+
replace github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.3.2+incompatible

0 commit comments

Comments
 (0)