Skip to content

Commit 5a07279

Browse files
kosta709kosta709
and
kosta709
authored
Dind storage r1 (#109)
* dind storage from master -draft1 * venona storage -1 * fixed node selector for runtime * fixed node selector for runtime * fixed uninstall * storage to README * single storage class * storage before merge 1 * storage before merge 1 Co-authored-by: kosta709 <[email protected]>
1 parent 30af2ba commit 5a07279

21 files changed

+984
-204
lines changed

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,88 @@ rules:
114114
* Bind your user with cluster-admin kubernetes clusterrole
115115
> `kubectl create clusterrolebinding NAME --clusterrole cluster-admin --user YOUR_USER`
116116

117+
#### Pipeline Storage with docker cache support
118+
119+
##### **GKE LocalSSD**
120+
*Prerequisite:* [GKE custer with local SSD](https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/local-ssd)
121+
122+
*Install venona for using GKE Local SSD:*
123+
```
124+
codefresh install runtime [options] \
125+
--set-value=Storage.LocalVolumeParentDir=/mnt/disks/ssd0/codefresh-volumes
126+
--kube-selector=cloud.google.com/gke-local-ssd=true
127+
```
128+
129+
##### **GCE Disks**
130+
*Prerequisite:* volume provisioner (dind-volume-provisioner) should have permissions to create/delete/get of google disks
131+
There are 3 options to provide cloud credentials on GCE:
132+
* run venona dind-volume-provisioniner on node with iam role which is allowed to create/delete/get of google disks
133+
* 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`
134+
* 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
135+
136+
*Note*: Builds will be running in single availability zone, so you must to specify AvailabilityZone params
137+
138+
139+
*Install venona for using GKE Disks:*
140+
```
141+
codefresh install runtime [options] \
142+
--set-value=Storage.Backend=gcedisk \
143+
--set-value=Storage.AvailabilityZone=us-central1-a \
144+
--kube-node-selector=failure-domain.beta.kubernetes.io/zone=us-central1-a \
145+
[--set-file=Storage.GoogleServiceAccount=/path/to/google-service-account.json]
146+
```
147+
148+
##### **Amazon EBS**
149+
150+
*Prerequisite:* volume provisioner (dind-volume-provisioner) should have permissions to create/delete/get of aws ebs
151+
Minimal iam policy for dind-volume-provisioner:
152+
```json
153+
{
154+
"Version": "2012-10-17",
155+
"Statement": [
156+
{
157+
"Effect": "Allow",
158+
"Action": [
159+
"ec2:AttachVolume",
160+
"ec2:CreateSnapshot",
161+
"ec2:CreateTags",
162+
"ec2:CreateVolume",
163+
"ec2:DeleteSnapshot",
164+
"ec2:DeleteTags",
165+
"ec2:DeleteVolume",
166+
"ec2:DescribeInstances",
167+
"ec2:DescribeSnapshots",
168+
"ec2:DescribeTags",
169+
"ec2:DescribeVolumes",
170+
"ec2:DetachVolume"
171+
],
172+
"Resource": "*"
173+
}
174+
]
175+
}
176+
```
177+
178+
There are 3 options to provide cloud credentials on AWS:
179+
* run venona dind-volume-provisioniner on node with the iam role - use `--set-value Storage.VolumeProvisioner.NodeSelector=node-label=value` option
180+
* 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`
181+
182+
* 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
183+
184+
*Notes*:
185+
- 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
186+
187+
- 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`)
188+
189+
*Install Command to run pipelines on ebs volumes*
190+
```
191+
codefresh install runtime [options] \
192+
--set-value=Storage.Backend=ebs \
193+
--set-value=Storage.AvailabilityZone=us-east-1d \
194+
--kube-node-selector=failure-domain.beta.kubernetes.io/zone=us-east-1d \
195+
[--set-value Storage.VolumeProvisioner.NodeSelector=kubernetes.io/role=master] \
196+
[--set-value Storage.AwsAccessKeyId=ABCDF --set-value Storage.AwsSecretAccessKey=ZYXWV]
197+
```
198+
117199
#### Kubernetes RBAC
118200
Installation of Venona on Kubernetes cluster installing 2 groups of objects,
119201
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": "1.0.7",
3+
"version": "1.0.8",
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-
1.0.7
1+
1.0.8

venonactl/cmd/cmdutils.go

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
"gopkg.in/yaml.v2"
2424
k8sApi "k8s.io/api/core/v1"
2525
"k8s.io/client-go/tools/clientcmd"
26+
27+
"helm.sh/helm/v3/pkg/strvals"
2628
)
2729

2830
var (
@@ -230,7 +232,55 @@ func extendStoreWithAgentAPI(logger logger.Logger, token string, agentID string)
230232
func (ns nodeSelector) String() string {
231233
var s string
232234
for k, v := range ns {
233-
s = fmt.Sprintf("%s: %s", k, v)
235+
s = fmt.Sprintf("%s: %q", k, v)
234236
}
235237
return s
236238
}
239+
240+
// Parsing helpers --set-value , --set-file
241+
// by https://github.com/helm/helm/blob/ec1d1a3d3eb672232f896f9d3b3d0797e4f519e3/pkg/cli/values/options.go#L41
242+
243+
// parses --set-value options
244+
func parseSetValues(setValuesOpts []string) (map[string]interface{}, error) {
245+
base := map[string]interface{}{}
246+
for _, value := range setValuesOpts {
247+
if err := strvals.ParseInto(value, base); err != nil {
248+
return nil, fmt.Errorf("Cannot parse option --set-value %s", value)
249+
}
250+
}
251+
return base, nil
252+
}
253+
254+
// parses --set-file options
255+
func parseSetFiles(setFilesOpts []string) (map[string]interface{}, error) {
256+
base := map[string]interface{}{}
257+
for _, value := range setFilesOpts {
258+
reader := func(rs []rune) (interface{}, error) {
259+
bytes, err := ioutil.ReadFile(string(rs))
260+
return string(bytes), err
261+
}
262+
if err := strvals.ParseIntoFile(value, base, reader); err != nil {
263+
return nil, fmt.Errorf("Cannot parse option --set-file %s", value)
264+
}
265+
}
266+
return base, nil
267+
}
268+
269+
func mergeMaps(a, b map[string]interface{}) map[string]interface{} {
270+
out := make(map[string]interface{}, len(a))
271+
for k, v := range a {
272+
out[k] = v
273+
}
274+
for k, v := range b {
275+
if v, ok := v.(map[string]interface{}); ok {
276+
if bv, ok := out[k]; ok {
277+
if bv, ok := bv.(map[string]interface{}); ok {
278+
out[k] = mergeMaps(bv, v)
279+
continue
280+
}
281+
}
282+
}
283+
out[k] = v
284+
}
285+
return out
286+
}

venonactl/cmd/install-runtime.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ var installRuntimeCmdOptions struct {
3232
namespace string
3333
inCluster bool
3434
context string
35+
nodeSelector string
3536
}
3637
storageClass string
3738
runtimeEnvironmentName string
3839
kubernetesRunnerType bool
3940
tolerations string
41+
templateValues []string
42+
templateFileValues []string
4043
}
4144

4245
var installRuntimeCmd = &cobra.Command{
@@ -78,6 +81,12 @@ var installRuntimeCmd = &cobra.Command{
7881
s.KubernetesAPI.Tolerations = tolerations
7982
}
8083

84+
kns, err := parseNodeSelector(installRuntimeCmdOptions.kube.nodeSelector)
85+
if err != nil {
86+
dieOnError(err)
87+
}
88+
s.KubernetesAPI.NodeSelector = kns.String()
89+
8190
builder := plugins.NewBuilder(lgr)
8291
isDefault := isUsingDefaultStorageClass(installRuntimeCmdOptions.storageClass)
8392

@@ -118,8 +127,24 @@ var installRuntimeCmd = &cobra.Command{
118127
}
119128

120129
builderInstallOpt.KubeBuilder = getKubeClientBuilder(s.KubernetesAPI.ContextName, s.KubernetesAPI.Namespace, s.KubernetesAPI.ConfigPath, s.KubernetesAPI.InCluster)
121-
var err error
122130
values := s.BuildValues()
131+
132+
if len(installRuntimeCmdOptions.templateValues) > 0 {
133+
setValues, err := parseSetValues(installRuntimeCmdOptions.templateValues)
134+
if err != nil {
135+
dieOnError(err)
136+
}
137+
values = mergeMaps(values, setValues)
138+
}
139+
140+
if len(installRuntimeCmdOptions.templateFileValues) > 0 {
141+
setFileValues, err := parseSetFiles(installRuntimeCmdOptions.templateFileValues)
142+
if err != nil {
143+
dieOnError(err)
144+
}
145+
values = mergeMaps(values, setFileValues)
146+
}
147+
123148
for _, p := range builder.Get() {
124149
values, err = p.Install(builderInstallOpt, values)
125150
if err != nil {
@@ -146,6 +171,10 @@ func init() {
146171
installRuntimeCmd.Flags().BoolVar(&installRuntimeCmdOptions.kube.inCluster, "in-cluster", false, "Set flag if venona is been installed from inside a cluster")
147172
installRuntimeCmd.Flags().BoolVar(&installRuntimeCmdOptions.dryRun, "dry-run", false, "Set to true to simulate installation")
148173
installRuntimeCmd.Flags().BoolVar(&installRuntimeCmdOptions.kubernetesRunnerType, "kubernetes-runner-type", false, "Set the runner type to kubernetes (alpha feature)")
174+
installRuntimeCmd.Flags().StringVar(&installRuntimeCmdOptions.kube.nodeSelector, "kube-node-selector", "", "The kubernetes node selector \"key=value\" to be used by venona resources (default is no node selector)")
149175
installRuntimeCmd.Flags().StringVar(&installRuntimeCmdOptions.tolerations, "tolerations", "", "The kubernetes tolerations as JSON string to be used by venona resources (default is no tolerations)")
150176

177+
installRuntimeCmd.Flags().StringArrayVar(&installRuntimeCmdOptions.templateValues, "set-value", []string{}, "Set values for templates, example: --set-value LocalVolumesDir=/mnt/disks/ssd0/codefresh-volumes")
178+
installRuntimeCmd.Flags().StringArrayVar(&installRuntimeCmdOptions.templateFileValues, "set-file", []string{}, "Set values for templates from file, example: --set-file Storage.GoogleServiceAccount=/path/to/service-account.json")
179+
151180
}

venonactl/cmd/uninstall-runtime.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ var uninstallRuntimeCmd = &cobra.Command{
3838

3939
s.CodefreshAPI = &store.CodefreshAPI{}
4040
s.AgentAPI = &store.AgentAPI{}
41-
4241

4342
builder := plugins.NewBuilder(lgr)
4443
if uninstallRunimeCmdOptions.kube.context == "" {
@@ -47,7 +46,8 @@ var uninstallRuntimeCmd = &cobra.Command{
4746
if uninstallRunimeCmdOptions.kube.namespace == "" {
4847
dieOnError(fmt.Errorf("Namespace name is required to in order to uninstall agent"))
4948
}
50-
49+
s.KubernetesAPI.ContextName = uninstallRunimeCmdOptions.kube.context
50+
s.KubernetesAPI.Namespace = uninstallRunimeCmdOptions.kube.namespace
5151

5252
if uninstallRunimeCmdOptions.kubeVenona.kubePath == "" {
5353
uninstallRunimeCmdOptions.kubeVenona.kubePath = kubeConfigPath

venonactl/go.mod

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,27 @@
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/gophercloud/gophercloud v0.8.0 // indirect
1812
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
13+
github.com/imdario/mergo v0.3.8 // indirect
14+
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1
15+
github.com/mattn/go-colorable v0.1.6 // indirect
2716
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
17+
github.com/spf13/cobra v0.0.6
18+
github.com/spf13/viper v1.6.2
19+
gopkg.in/yaml.v2 v2.2.8
20+
helm.sh/helm/v3 v3.1.1
21+
k8s.io/api v0.17.3
22+
k8s.io/apimachinery v0.17.3
23+
k8s.io/client-go v0.17.3
24+
k8s.io/utils v0.0.0-20200229041039-0a110f9eb7ab // indirect
4025
)
4126

42-
replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20181218151757-9b75e4fe745a
43-
44-
replace github.com/census-instrumentation/opencensus-proto => github.com/census-instrumentation/opencensus-proto v0.0.3-0.20181214143942-ba49f56771b8
45-
46-
go 1.13
27+
replace github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.3.2+incompatible

0 commit comments

Comments
 (0)