Skip to content

Commit 70510f3

Browse files
Saas 5009 (#88)
Introduce V1 : install agent install runtime attach runtime uninstall agent uninstall runtime
1 parent f391650 commit 70510f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1943
-855
lines changed

.codefresh/codefresh.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ steps:
2222
commands:
2323
- export VERSION=$(jq -r ".version" package.json)
2424
- cf_export VERSION
25-
# - export FILE_VERSION= $(cat ./venonactl/VERSION)
2625
- cf_export FILE_VERSION=$(cat ./venonactl/VERSION)
2726
when:
2827
steps:

.codefresh/test-agent.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
version: '1.0'
2+
3+
stages:
4+
- Test
5+
- Notification
6+
7+
steps:
8+
9+
create_namespace:
10+
stage: Notification
11+
title: 'Create namespace in Kuberentes'
12+
image: codefresh/kube-helm
13+
commands:
14+
- kubectl config set-context $KUEB_CONTEXT
15+
- kubectl create namespace $KUBE_NAMESPACE
16+
17+
install_agent:
18+
stage: Notification
19+
title: 'Install agent'
20+
image: codefresh/cli
21+
commands:
22+
# Install agent, runtime and attach it
23+
- codefresh install agent --name $AGENT_NAME --kube-namespace $KUBE_NAMESPACE --install-runtime --kube-context-name $KUEB_CONTEXT --kube-config-path $KUBECONFIG
24+
- codefresh run $TEST_PIPELINE_ID
25+
26+
uninstall_agent:
27+
stage: Notification
28+
title: 'Uninstall agent'
29+
image: codefresh/cli
30+
commands:
31+
# Uninstall agent, runtime
32+
- codefresh uninstall agent --name $AGENT_NAME --kube-namespace $KUBE_NAMESPACE
33+
- codefresh uninstall runtime --runtime-name $KUEB_CONTEXT/$KUBE_NAMESPACE --kube-namespace $KUBE_NAMESPACE --kube-context-name $KUEB_CONTEXT --kube-config-path $KUBECONFIG
34+
- echo "removed"
35+
36+
delete_namespace:
37+
stage: Notification
38+
title: 'Create namespace in Kuberentes'
39+
image: codefresh/kube-helm
40+
commands:
41+
- kubectl delete namespace $KUBE_NAMESPACE
42+
43+
when:
44+
steps:
45+
- name: create_namespace
46+
on:
47+
- success
48+
49+
reported_failure:
50+
stage: Notification
51+
title: Report failure to Slack
52+
type: slack-message-sender
53+
arguments:
54+
WEBHOOK_URL: $SLACK_WEBHOOK_URL
55+
MESSAGE: "Venona installation failed, link: $CF_BUILD_URL"
56+
when:
57+
steps:
58+
any:
59+
- name: create_namespace
60+
on:
61+
- failure
62+
- name: create_namespace
63+
on:
64+
- failure
65+
- name: delete_namespace
66+
on:
67+
- failure
68+
- name: uninstall_agent
69+
on:
70+
- failure
71+

.eslintrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ rules:
2323
semi:
2424
- error
2525
- always
26-
"jest/no-disabled-tests": "warn"
26+
"jest/no-disabled-tests": "error"
2727
"jest/no-focused-tests": "error"
2828
"jest/no-identical-title": "error"
2929
"jest/prefer-to-have-length": "warn"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ telepresence.log
1616
venonactl/dist/*
1717
venonactl-linux
1818
venonalog.json
19+
.venonaconf

README.md

Lines changed: 70 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,72 @@
22
[![Go Report Card](https://goreportcard.com/badge/github.com/codefresh-io/venona)](https://goreportcard.com/report/github.com/codefresh-io/venona)
33
[![Codefresh build status]( https://g.codefresh.io/api/badges/pipeline/codefresh-inc/codefresh-io%2Fvenona%2Fvenona?type=cf-1)]( https://g.codefresh.io/public/accounts/codefresh-inc/pipelines/codefresh-io/venona/venona)
44

5+
## Version 1.x.x
6+
Version 1.0.0 is released now, read more about migration from older version [here](#Migration)
7+
We highly suggest to use [Codefresh official CLI](https://codefresh-io.github.io/cli/) to install the agent:
8+
```bash
9+
kubectl create namespace codefresh
10+
codefresh install agent --kube-namespace codefresh --install-runtime
11+
```
12+
13+
The last command will:
14+
1. Install the agent on the namespace `codefresh`
15+
2. Install the runtime on the same namespace
16+
3. Attach the runtime to the agent
17+
18+
It is still possible, for advanced users to install all manually, for example:
19+
One process of Venona can manage multiple runtime environments
20+
NOTE: Please make sure that the process where Venona is installed there is a network connection to the clusters where the runtimes will be installed
21+
```bash
22+
# 1. Create namespace for the agent:
23+
kubectl create namespace codefresh-agent
24+
25+
# 2. Install the agent on the namespace ( give your agent a unique):
26+
# Print a token that the Venona process will be using.
27+
codefresh create agent $NAME
28+
codefresh install agent --token $TOKEN --kube-namespace codefresh-agent
29+
30+
# 3. Create namespace for the first runtime:
31+
kubectl create namespace codefresh-runtime-1
32+
33+
# 4. Install the first runtime on the namespace
34+
# 5. the runtime name is printed
35+
codefresh install runtime --kube-namespace codefresh-runtime-1
36+
37+
# 6. Attach the first runtime to agent:
38+
codefresh attach runtime --agent-name $AGENT_NAME --agent-kube-namespace codefresh-agent --runtime-name $RUNTIME_NAME --kube-namespace codefresh-runtime-1
39+
40+
# 7. Restart the venona pod in namespace `codefresh-agent`
41+
kubectl delete pods $VENONA_POD
42+
43+
# 8. Create namespace for the second runtime
44+
kubectl create namespace codefresh-runtime-2
45+
46+
# 9. Install the second runtime on the namespace
47+
codefresh install runtime --kube-namespace codefresh-runtime-2
48+
49+
# 10. Attach the second runtime to agent and restart the Venoa pod automatically
50+
codefresh attach runtime --agent-name $AGENT_NAME --agent-kube-namespace codefresh-agent --runtime-name $RUNTIME_NAME --runtime-kube-namespace codefresh-runtime-1 --restart-agent
51+
52+
```
53+
54+
## Migration
55+
Migrating from Venona `< 1.x.x` to `> 1.x.x` is not done automatically, please use the [migration script](https://github.com/codefresh-io/venona/blob/master/scripts/migration.sh) to do that, check out which environment variables are required to run it.
56+
```bash
57+
# This script comes to migrate old versions of Venona installation ( version < 1.x.x ) to new version (version >= 1.0.0 )
58+
# Please read carefully what the script does.
59+
# There will be a "downtime" in terms of your builds targeted to this runtime environment
60+
# Once the script is finished, all the builds during the downtime will start
61+
# The script will:
62+
# 1. Create new agent entity in Codefresh using Codefresh CLI - give it a name $CODEFRESH_AGENT_NAME, default is "codefresh"
63+
# 2. Install the agent on you cluster pass variables:
64+
# a. $VENONA_KUBE_NAMESPACE - required
65+
# b. $VENONA_KUBE_CONTEXT - default is current-context
66+
# c. $VENONA_KUBECONFIG_PATH - default is $HOME/.kube/config
67+
# 3. Attach runtime to the new agent (downtime ends) - pass $CODEFRESH_RUNTIME_NAME - required
68+
```
69+
70+
571
## Installation
672

773
### Prerequisite:
@@ -12,42 +78,13 @@
1278
* [Codefresh](https://codefresh-io.github.io/cli/) - Used to create resource in Codefresh
1379
* Authenticated context exist under `$HOME/.cfconfig` or authenticate with [Codefesh CLI](https://codefresh-io.github.io/cli/getting-started/#authenticate)
1480

15-
1681
### Install venona
1782

1883
* Download [venona's](https://github.com/codefresh-io/venona/releases) binary
1984
* With homebrew:
2085
* `brew tap codefresh-io/venona`
2186
* `brew install venona`
22-
* Create namespace where venona should run<br />
23-
> `kubectl create namespace codefresh-runtime`
24-
* Create *new* runtime-environment with Venona's agents installed <br />
25-
> `venona install --kube-namespace codefresh-runtime`
26-
* Get the status <br />
27-
> `venona status`
28-
> `kubectl get pods -n codefresh-runtime`
29-
30-
#### Install Options
31-
32-
| Option Argument | Type | Description |
33-
| -------------------- | -------- | --------------------------------------------------- |
34-
| --build-annotations | stringArray | The kubernetes metadata.annotations as "key=value" to be used by venona build resources (default is no node selector) |
35-
| --build-node-selector | string | The kubernetes node selector "key=value" to be used by venona build resources (default is no node selector) |
36-
| --cluster-name | string | cluster name (if not passed runtime-environment will be created cluster-less); this is a friendly name used for metadata does not need to match the literal cluster name. Limited to 20 Characters. |
37-
| --dry-run | boolean | Set to true to simulate installation |
38-
| -h, --help | boolean | help for install |
39-
| --in-cluster | boolean | Set flag if venona is been installed from inside a cluster |
40-
| --kube-context-name | string | Name of the kubernetes context on which venona should be installed (default is current-context) [$KUBE_CONTEXT] |
41-
| --kube-namespace | string |Name of the namespace on which venona should be installed [$KUBE_NAMESPACE] |
42-
| --kube-node-selector | string | The kubernetes node selector "key=value" to be used by venona resources (default is no node selector) |
43-
| --kubernetes-runner-type | boolean | Set the runner type to kubernetes (alpha feature) |
44-
| --only-runtime-environment | boolean | Set to true to onlky configure namespace as runtime-environment for Codefresh |
45-
| --runtime-environment | string | if --skip-runtime-installation set, will try to configure venona on current runtime-environment |
46-
| --set-default | boolean | Mark the install runtime-environment as default one after installation |
47-
| --skip-runtime-installation | boolean | Set flag if you already have a configured runtime-environment, add --runtime-environment flag with name |
48-
| --storage-class | string | Set a name of your custom storage class, note: this will not install volume provisioning components |
49-
| --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-
| --venona-version | string | Version of venona to install (default is the latest) |
87+
5188

5289
#### Install on cluster version < 1.10
5390
* Make sure the `PersistentLocalVolumes` [feature gate](https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/) is turned on
@@ -78,27 +115,11 @@ Each one has own RBAC needs and therefore, created roles(and cluster-roles)
78115
The resource descriptors are avaliable [here](https://github.com/codefresh-io/venona/tree/master/venonactl/templates/kubernetes)
79116
List of the resources that will be created
80117
* Agent (grouped by `/.*.venona.yaml/`)
81-
* `service-account.venona.yaml` - The service account that the agent's pod will use at the end
118+
* `service-account.re.yaml` - The service account that the Venona pod will use to create the resource on the runtime namespace(the resoucre installed on the runtime namespace)
119+
* `role.re.yaml` - Allow to GET, CREATE and DELETE pods and persistentvolumeclaims
120+
* `role-binding.re.yaml` - The agent is spinning up pods and pvc, this biniding binds `role.venona.yaml` to `service-account.venona.yaml`
82121
* `cluster-role-binding.venona.yaml` - The agent discovering K8S apis by calling to `openapi/v2`, this ClusterRoleBinding binds bootstraped ClusterRole by Kubernetes `system:discovery` to `service-account.venona.yaml`. This role has only permissions to make a GET calls to non resources urls
83-
* `role.venona.yaml` - Allow to GET, CREATE and DELETE pods and persistentvolumeclaims
84-
* `role-binding.venona.yaml` - The agent is spinning up pods and pvc, this biniding binds `role.venona.yaml` to `service-account.venona.yaml`
85122
* Runtime-environment (grouped by `/.*.re.yaml/`) Kubernetes controller that spins up all required resources to provide a good caching expirience during pipeline execution
86123
* `service-account.dind-volume-provisioner.re.yaml` - The service account that the controller will use
87124
* `cluster-role.dind-volume-provisioner.re.yaml` Defines all the permission needed for the controller to operate correctly
88125
* `cluster-role-binding.dind-volume-provisioner.yaml` - Binds the ClusterRole to `service-account.dind-volume-provisioner.re.yaml`
89-
90-
### Access the cluster from executed pipeline
91-
After a successfull installation of Venona, you'll be able to run a Codefresh pipeline on the configured cluster.
92-
However, the pipeline itself dosent have any permission to connect to the hosted cluster.
93-
To make it work you need to add the cluster to Codefresh (make sure the service acount has all the permissions you need)
94-
> codefresh create cluster --kube-context CONTEXT_NAME --namespace NAMESPACE --serviceaccount SERVICE_ACCOUNT --behind-firewall
95-
96-
#### Upgrade
97-
To upgrade existing runtime-environment, a one that was created without Venona's agent, run:
98-
* Find the name of the cluster was linked to that runtime environment <br />
99-
Example: `codefresh get cluster`
100-
* Install <br />
101-
Example: `venona install --cluster-name CLUSTER`
102-
* Get the status <br />
103-
Example: `venona status RUNTIME-ENVIRONMENT`
104-
Example: `kubectl get pods -n NAMESPACE`

__mocks__/recursive-readdir.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
let files = [];
2+
3+
const recursive = async (path, ignore, cb) => {
4+
return cb(null, files);
5+
};
6+
7+
recursive.__setFiles = (names) => {
8+
files = files.concat(names);
9+
};
10+
11+
recursive.__clear = () => {
12+
files = [];
13+
};
14+
15+
module.exports = recursive;

0 commit comments

Comments
 (0)