Skip to content

Commit 371fedb

Browse files
fix: Upgrade deployment to unikraft cli
Signed-off-by: Dragos Gheorghioiu <dragosg@unikraft.com>
1 parent 9cabcc4 commit 371fedb

4 files changed

Lines changed: 79 additions & 68 deletions

File tree

.github/actions/setup-kraftkit/action.yaml

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: setup-unikraft
2+
3+
description: |
4+
Install the Unikraft CLI and configure a profile for Unikraft Cloud.
5+
6+
inputs:
7+
token:
8+
required: true
9+
description: Unikraft Cloud API token.
10+
metro:
11+
required: true
12+
description: Unikraft Cloud metro endpoint (e.g. https://api.dal2.unikraft.cloud).
13+
profile:
14+
required: false
15+
default: oss-www
16+
description: Name of the CLI profile to configure and activate.
17+
version:
18+
required: false
19+
default: latest
20+
description: Unikraft CLI version to install.
21+
22+
runs:
23+
using: composite
24+
steps:
25+
- name: Install Unikraft CLI
26+
uses: unikraft/setup-action@v1
27+
with:
28+
version: ${{ inputs.version }}
29+
30+
- name: Configure profile
31+
shell: bash
32+
env:
33+
UKC_TOKEN: ${{ inputs.token }}
34+
UKC_METRO: ${{ inputs.metro }}
35+
PROFILE: ${{ inputs.profile }}
36+
run: |
37+
mkdir -p "$HOME/.config/unikraft"
38+
cat > "$HOME/.config/unikraft/config.yaml" << EOF
39+
profile: ${PROFILE}
40+
profiles:
41+
${PROFILE}:
42+
type: cloud
43+
token: ${UKC_TOKEN}
44+
metros:
45+
- name: ${PROFILE}
46+
endpoint: ${UKC_METRO%}
47+
EOF

.github/actions/setup-www/action.yaml

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,14 @@ inputs:
1313
domain:
1414
required: false
1515
description: The domain to use for the deployment.
16-
metro:
17-
required: false
18-
description: Unikraft Cloud Metro.
19-
default: http://api.dal2.unikraft.cloud/v1
2016
memory:
2117
required: false
2218
description: Set the memory size.
23-
default: 1536Mi
24-
args:
25-
required: false
26-
description: Optional arguments you pass to kraft cloud deploy.
19+
default: 1536M
2720
port:
2821
required: false
2922
description: The port the service listens on.
3023
default: "3000"
31-
log-level:
32-
required: false
33-
default: error
34-
description: Set the logging level.
3524

3625
outputs:
3726
domain:
@@ -58,39 +47,39 @@ runs:
5847
set -e;
5948
6049
# Create the service if it does not exist.
61-
_SVC=$(kraft cloud --metro "${{ inputs.metro }}" service get "${{ inputs.name }}" -o raw | jq -r '.data.service_groups[].error')
62-
if [[ "${_SVC}" == "8" ]]; then
63-
if [[ "${{ inputs.domain }}" == "" ]]; then
64-
kraft cloud --metro "${{ inputs.metro }}" service create \
65-
--subdomain "${{ inputs.name }}" \
66-
--name "${{ inputs.name }}" \
67-
"443:${{ inputs.port }}" \
68-
;
69-
else
70-
kraft cloud --metro "${{ inputs.metro }}" service create \
71-
--domain "${{ inputs.domain }}" \
72-
--name "${{ inputs.name }}" \
73-
"443:${{ inputs.port }}" \
74-
;
75-
fi
50+
if ! unikraft service get "${{ inputs.name }}" -o quiet 2>/dev/null; then
51+
unikraft service create \
52+
--domains "${{ inputs.domain || inputs.name }}" \
53+
--name "${{ inputs.name }}" \
54+
--services "443:${{ inputs.port }}/http+tls" \
55+
;
7656
fi
7757
7858
# Save the generated domain as an output variable
79-
echo "domain=$(kraft cloud --metro ${{ inputs.metro }} service get ${{ inputs.name }} -o raw | jq -r '.data.service_groups[0].domains[0].fqdn')" >> $GITHUB_OUTPUT
59+
echo "domain=$(unikraft service get ${{ inputs.name }} -o json | jq -r '.[0].domains[0].fqdn')" >> $GITHUB_OUTPUT
8060
8161
- name: Deploy
8262
id: deploy
8363
shell: bash
8464
run: |
85-
kraft cloud deploy \
86-
--rollout remove \
87-
--rollout-qualifier all \
65+
unikraft build \
66+
--output "oci://internal/${{ inputs.name }}:latest" \
67+
.;
68+
69+
# Remove any existing instance(s) on this service before running the
70+
# new one, so the service always ends up with just the latest build.
71+
unikraft instance delete \
72+
--filter "service.name==${{ inputs.name }}" \
73+
--force \
74+
2>/dev/null || true;
75+
76+
unikraft run \
77+
--autostart \
78+
--restart always \
8879
--memory "${{ inputs.memory }}" \
8980
--service "${{ inputs.name }}" \
90-
--image "${{ inputs.name }}" \
91-
--as kraftfile-runtime \
92-
${{ inputs.args }} \
93-
.;
81+
--image "internal/${{ inputs.name }}:latest" \
82+
;
9483
9584
- name: Test liveliness
9685
id: liveliness
@@ -104,7 +93,8 @@ runs:
10493
if: ${{ steps.liveliness.outcome == 'failure' }}
10594
shell: bash
10695
run: |
107-
kraft cloud service logs "${{ inputs.name }}"
96+
_INST=$(unikraft service get "${{ inputs.name }}" -o json | jq -r '.[0].instances[0].name')
97+
unikraft instance logs "${_INST}"
10898
exit 1
10999
110100
- name: Update Deployment

.github/workflows/main.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ on:
1212
env:
1313
UKC_TOKEN: ${{ secrets.UKC_TOKEN }}
1414
UKC_METRO: ${{ secrets.UKC_METRO }}
15-
KRAFTKIT_LOG_LEVEL: debug
16-
KRAFTKIT_NO_CHECK_UPDATES: "true"
15+
UNIKRAFT_LOG_LEVEL: debug
1716

1817
permissions:
1918
deployments: write
@@ -38,8 +37,11 @@ jobs:
3837
exit 1
3938
fi
4039
41-
- name: Setup KraftKit
42-
uses: ./.github/actions/setup-kraftkit
40+
- name: Setup Unikraft CLI
41+
uses: ./.github/actions/setup-unikraft
42+
with:
43+
token: ${{ secrets.UKC_TOKEN }}
44+
metro: ${{ secrets.UKC_METRO }}
4345

4446
- name: Setup OSS docs website
4547
id: www
@@ -49,8 +51,6 @@ jobs:
4951
environment: main
5052
name: oss-www
5153
domain: unikraft.org
52-
metro: ${{ secrets.UKC_METRO }}
53-
log-level: trace
5454

5555
- uses: chrnorm/deployment-action@v2
5656
name: Create GitHub deployment

0 commit comments

Comments
 (0)