Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
rafay: rafaysystems/rafay@1.0.7
Use rafay
elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
Builds the source code from your repo as a container image and deploys it as a workload to rafay platform.
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
orbs:
rafay: rafaysystems/rafay@x.y.z
version: 2.1
jobs:
build-job:
executor: rafay/default
steps:
- run: echo "Run your build steps here"
Publish-Workload:
executor: rafay/default
steps:
- checkout
- rafay/init
- rafay/add_workload:
yaml_file: workload.yml
- rafay/set_workload_image:
workload: demo-circleci
container: httpbin
image: $RAFAY_REGISTRY_ENDPOINT/$RAFAY_ORGANIZATION_LABEL/httpbin
tag: $CIRCLE_SHA1
- rafay/publish_workload:
workload: demo-circleci
- rafay/check_workload_status:
workload: demo-circleci
Test-Workload:
executor: rafay/default
steps:
- run: echo "Run your tests here"
Delete-Workload:
executor: rafay/default
steps:
- rafay/init
- rafay/delete_workload:
workload: demo-circleci
workflows:
version: 2
build-and-publish-workload-to-rafay:
jobs:
- build-job
- Publish-Workload:
requires:
- build-job
- Test-Workload:
requires:
- build-job
- Publish-Workload
- Delete-Workload:
requires:
- build-job
- Publish-Workload
- Test-Workload
Initializes Rafay CLI.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
rctl_api_key | Env variable storing your API key | No | RCTL_API_KEY | env_var_name |
rctl_secret_key | Env variable storing your API Secret | No | RCTL_API_SECRET | env_var_name |
rctl_rest_endpoint | Env Variable storing your Rafay Rest Endpoint | No | RCTL_REST_ENDPOINT | env_var_name |
rctl_project | Env Variable storing your Rafay Project | No | RCTL_PROJECT | env_var_name |
rafay_username | Env variable storing your Username | No | RAFAY_USERNAME | env_var_name |
rafay_registry | Env Variable storing your Rafay Registry | No | RAFAY_REGISTRY_ENDPOINT | env_var_name |
rctl_ops_endpoint | Env Variable storing your Rafay Ops Endpoint | No | RCTL_OPS_ENDPOINT | env_var_name |
rafay_registry_secret | Env Variable storing your Rafay Registry Secret | No | RAFAY_REGISTRY_SECRET | env_var_name |
rafay_organization_label | Env Variable storing your Rafay Organization Label | No | RAFAY_ORGANIZATION_LABEL | env_var_name |
rafay_cli_log | Env Variable storing your Rafay CLI Log | No | RAFAY_CLI_LOG_FILE_LOCATION | env_var_name |
Adds a workload to Rafay Platform.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
yaml_file | Yaml file consisting of the workload config | Yes | - | string |
Sets an image to a container in a workload
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
workload | Name of the workload | Yes | - | string |
container | Name of the container in a workload | Yes | - | string |
image | Name of the Image | Yes | - | string |
tag | Tag of the Image | Yes | - | string |
Updates an already created workload on Rafay Platform.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
yaml_file | Yaml file consisting of the workload config | Yes | - | string |
Publish a workload on Rafay Platform.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
workload | Name of the workload | Yes | - | string |
Deletes a workload on Rafay Platform.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
workload | Name of the workload | Yes | - | string |
Check the publish status of a workload on Rafay Platform.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
workload | Name of the workload | Yes | - | string |
Configure the workload on Rafay Platform.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
yaml_file | Yaml file consisting of the workload config | Yes | - | string |
workload | Name of the workload | Yes | - | string |
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
# This code is licensed from CircleCI to the user under the MIT license. See
# https://circleci.com/orbs/registry/licensing for details.
version: 2.1
description: |
Deploy a Kubernetes Cluster from CircleCI using the Rafay Systems Platform. Rafay’s turnkey SaaS platform automates the highly complex deployment and operational workflows that DevOps and SRE teams implement to operate Kubernetes clusters and Kubernetes-resident apps across clusters in cloud and data center environments. The platform accelerates organizations’ respective application modernization journeys by abstracting away the complexities of Kubernetes and other open-source container management tools. Learn more: https://rafay.co/enterprise-integrations/circleci
display:
source_url: https://github.com/RafaySystems/circleci-orb
home_url: https://rafay.co
commands:
init:
description: Initializes Rafay CLI.
parameters:
rctl_api_key:
description: Env variable storing your API key
type: env_var_name
default: RCTL_API_KEY
rctl_secret_key:
description: Env variable storing your API Secret
type: env_var_name
default: RCTL_API_SECRET
rctl_rest_endpoint:
description: Env Variable storing your Rafay Rest Endpoint
type: env_var_name
default: RCTL_REST_ENDPOINT
rctl_project:
description: Env Variable storing your Rafay Project
type: env_var_name
default: RCTL_PROJECT
rafay_username:
description: Env variable storing your Username
type: env_var_name
default: RAFAY_USERNAME
rafay_registry:
description: Env Variable storing your Rafay Registry
type: env_var_name
default: RAFAY_REGISTRY_ENDPOINT
rctl_ops_endpoint:
description: Env Variable storing your Rafay Ops Endpoint
type: env_var_name
default: RCTL_OPS_ENDPOINT
rafay_registry_secret:
description: Env Variable storing your Rafay Registry Secret
type: env_var_name
default: RAFAY_REGISTRY_SECRET
rafay_organization_label:
description: Env Variable storing your Rafay Organization Label
type: env_var_name
default: RAFAY_ORGANIZATION_LABEL
rafay_cli_log:
description: Env Variable storing your Rafay CLI Log
type: env_var_name
default: RAFAY_CLI_LOG_FILE_LOCATION
steps:
- run:
command: |
wget -O ${HOME}/rctl-linux-amd64.tar.bz2 https://s3-us-west-2.amazonaws.com/rafay-prod-cli/publish/rctl-linux-amd64.tar.bz2
tar -C ${HOME} -xf ${HOME}/rctl-linux-amd64.tar.bz2
chmod 0755 ${HOME}/rctl
mkdir -p ${HOME}/.rafay/cli
add_workload:
description: Adds a workload to Rafay Platform.
parameters:
yaml_file:
description: Yaml file consisting of the workload config
type: string
steps:
- run:
${HOME}/rctl create workload <<parameters.yaml_file>>
set_workload_image:
description: Sets an image to a container in a workload
parameters:
workload:
description: Name of the workload
type: string
container:
description: Name of the container in a workload
type: string
image:
description: Name of the Image
type: string
tag:
description: Tag of the Image
type: string
steps:
- run:
${HOME}/rctl workload set-image <<parameters.workload>> <<parameters.container>> <<parameters.image>>:<<parameters.tag>>
update_workload:
description: Updates an already created workload on Rafay Platform.
parameters:
yaml_file:
description: Yaml file consisting of the workload config
type: string
steps:
- run:
${HOME}/rctl update workload <<parameters.yaml_file>>
publish_workload:
description: Publish a workload on Rafay Platform.
parameters:
workload:
description: Name of the workload
type: string
steps:
- run:
${HOME}/rctl publish workload <<parameters.workload>>
delete_workload:
description: Deletes a workload on Rafay Platform.
parameters:
workload:
description: Name of the workload
type: string
steps:
- run:
${HOME}/rctl delete workload <<parameters.workload>>
check_workload_status:
description: Check the publish status of a workload on Rafay Platform.
parameters:
workload:
description: Name of the workload
type: string
steps:
- run:
command: |
workload_status="Not Ready"
workload_status_iterations=1
while [ "$workload_status" != "Ready" ];
do
workload_status=`${HOME}/rctl status workload <<parameters.workload>> -o json|jq .result[].status|tr -d '"'`
echo $workload_status
sleep 30
if [ $workload_status_iterations -ge 30 ];
then
break
fi
if [ "$workload_status" = "Failed" ];
then
echo "Workload Deployment Failed"
break
fi
workload_status_iterations=$((workload_status_iterations+1))
done
configure_workload:
description: Configure the workload on Rafay Platform.
parameters:
yaml_file:
description: Yaml file consisting of the workload config
type: string
workload:
description: Name of the workload
type: string
steps:
- run:
command: |
LookupWorkload () {
local workload match="$1"
shift
for workload; do [[ "$workload" == "$match" ]] && echo "yes"; done
echo "no"
}
wl_tmp=`${HOME}/rctl get workload -o json | jq 'select(.result | length > 0)|.result[]|.name' |cut -d'"' -f2`
WL_TMP_ARRAY=( $wl_tmp )
wl_exist=$(LookupWorkload <<parameters.workload>> "${WL_TMP_ARRAY[@]}")
if [ "$wl_exist" == "no" ];
then
${HOME}/rctl create workload <<parameters.yaml_file>>
else
${HOME}/rctl update workload <<parameters.yaml_file>>
fi
executors:
default:
description: |
This is a machine executor.
machine: true
examples:
build_and_deploy_workload_to_rafay:
description: |
Builds the source code from your repo as a container image and deploys it as a workload to rafay platform.
usage:
orbs:
rafay: rafaysystems/rafay@x.y.z
version: 2.1
jobs:
build-job:
executor: rafay/default
steps:
- run: echo "Run your build steps here"
Publish-Workload:
executor: rafay/default
steps:
- checkout
- rafay/init
- rafay/add_workload:
yaml_file: workload.yml
- rafay/set_workload_image:
workload: demo-circleci
container: httpbin
image: $RAFAY_REGISTRY_ENDPOINT/$RAFAY_ORGANIZATION_LABEL/httpbin
tag: $CIRCLE_SHA1
- rafay/publish_workload:
workload: demo-circleci
- rafay/check_workload_status:
workload: demo-circleci
Test-Workload:
executor: rafay/default
steps:
- run: echo "Run your tests here"
Delete-Workload:
executor: rafay/default
steps:
- rafay/init
- rafay/delete_workload:
workload: demo-circleci
workflows:
version: 2
build-and-publish-workload-to-rafay:
jobs:
- build-job
- Publish-Workload:
requires:
- build-job
- Test-Workload:
requires:
- build-job
- Publish-Workload
- Delete-Workload:
requires:
- build-job
- Publish-Workload
- Test-Workload