Skip to content

Commit 3eb35d1

Browse files
committed
wip
1 parent 67694e3 commit 3eb35d1

3 files changed

Lines changed: 252 additions & 0 deletions

File tree

.github/workflows/publish-azure-cc-enclave-docker.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,73 @@ jobs:
242242
# operator_type: azure
243243
# operator_image_version: ${{ needs.buildImage.outputs.image_tag }}
244244
# secrets: inherit
245+
246+
azureVn:
247+
name: Azure VN
248+
runs-on: ubuntu-latest
249+
permissions: {}
250+
needs: buildImage
251+
env:
252+
ARTIFACT_PREFIX: azure-vn-
253+
steps:
254+
- name: Checkout
255+
uses: actions/checkout@v4
256+
257+
- name: Install Azure CLI
258+
uses: ./.github/actions/install_az_cli
259+
260+
- name: check azure-cli version
261+
run: |
262+
az --version
263+
264+
- name: Generate Azure deployment artifacts
265+
env:
266+
IMAGE: ${{ needs.buildImage.outputs.tags }}
267+
OUTPUT_DIR: ${{ env.ARTIFACTS_OUTPUT_DIR }}
268+
MANIFEST_DIR: ${{ env.MANIFEST_OUTPUT_DIR }}
269+
VERSION_NUMBER: ${{ needs.buildImage.outputs.jar_version }}
270+
run: |
271+
bash ./scripts/azure-vn/deployment/generate-deployment-artifacts.sh
272+
273+
- name: Upload deployment artifacts
274+
uses: actions/upload-artifact@v4
275+
with:
276+
name: ${{ env.ARTIFACT_PREFIX }}deployment-files-${{ needs.buildImage.outputs.jar_version }}
277+
path: ${{ env.ARTIFACTS_OUTPUT_DIR }}
278+
if-no-files-found: error
279+
280+
- name: Upload manifest
281+
uses: actions/upload-artifact@v4
282+
with:
283+
name: ${{ env.ARTIFACT_PREFIX }}enclave-id-${{ needs.buildImage.outputs.jar_version }}
284+
path: ${{ env.MANIFEST_OUTPUT_DIR }}
285+
if-no-files-found: error
286+
287+
- name: Generate release archive
288+
if: ${{ inputs.version_number_input == '' && needs.buildImage.outputs.is_release == 'true' }}
289+
run: |
290+
zip -j ${{ env.ARTIFACTS_OUTPUT_DIR }}/uid2-operator-deployment-artifacts-${{ needs.buildImage.outputs.docker_version }}.zip ${{ env.ARTIFACTS_OUTPUT_DIR }}/*
291+
292+
- name: Build changelog
293+
id: github_release
294+
if: ${{ inputs.version_number_input == '' && needs.buildImage.outputs.is_release == 'true' }}
295+
uses: mikepenz/release-changelog-builder-action@v4
296+
with:
297+
configurationJson: |
298+
{
299+
"template": "#{{CHANGELOG}}\n## Installation\n```\ndocker pull ${{ needs.buildImage.outputs.tags }}\n```\n\n## Image reference to deploy: \n```\n${{ needs.buildImage.outputs.image_tag }}\n```\n\n## Changelog\n#{{UNCATEGORIZED}}",
300+
"pr_template": " - #{{TITLE}} - ( PR: ##{{NUMBER}} )"
301+
}
302+
env:
303+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
304+
305+
- name: Create release
306+
if: ${{ inputs.version_number_input == '' && needs.buildImage.outputs.is_release == 'true' }}
307+
uses: softprops/action-gh-release@v2
308+
with:
309+
name: ${{ needs.buildImage.outputs.jar_version }}
310+
body: ${{ steps.github_release.outputs.changelog }}
311+
draft: true
312+
files: |
313+
${{ env.ARTIFACTS_OUTPUT_DIR }}/uid2-operator-deployment-artifacts-${{ needs.buildImage.outputs.jar_version }}.zip
314+
${{ env.MANIFEST_OUTPUT_DIR }}/${{ env.ARTIFACT_PREFIX }}operator-digest-${{ needs.buildImage.outputs.jar_version }}.txt
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/usr/bin/env bash
2+
set -x
3+
4+
# Following environment variables must be set
5+
# - IMAGE: uid2-operator image
6+
# - OUTPUT_DIR: output directory to store the artifacts
7+
# - MANIFEST_DIR: output directory to store the manifest for the enclave Id
8+
# - VERSION_NUMBER: the version number of the build
9+
10+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
11+
INPUT_DIR=${SCRIPT_DIR}
12+
13+
if [[ -z ${IMAGE} ]]; then
14+
echo "IMAGE cannot be empty"
15+
exit 1
16+
fi
17+
IMAGE_VERSION=$(echo $IMAGE | awk -F':' '{print $2}')
18+
if [[ -z ${IMAGE_VERSION} ]]; then
19+
echo "Failed to extract image version from ${IMAGE}"
20+
exit 1
21+
fi
22+
23+
if [[ -z ${OUTPUT_DIR} ]]; then
24+
echo "OUTPUT_DIR cannot be empty"
25+
exit 1
26+
fi
27+
28+
mkdir -p ${OUTPUT_DIR}
29+
if [[ $? -ne 0 ]]; then
30+
echo "Failed to create ${OUTPUT_DIR}"
31+
exit 1
32+
fi
33+
34+
mkdir -p ${MANIFEST_DIR}
35+
if [[ $? -ne 0 ]]; then
36+
echo "Failed to create ${MANIFEST_DIR}"
37+
exit 1
38+
fi
39+
40+
# Input files
41+
INPUT_FILES=(
42+
operator.json operator.parameters.json
43+
vault.json vault.parameters.json
44+
vnet.json vnet.parameters.json
45+
gateway.json gateway.parameters.json
46+
)
47+
48+
# Copy input files to output dir
49+
for f in ${INPUT_FILES[@]}; do
50+
cp ${INPUT_DIR}/${f} ${OUTPUT_DIR}/${f}
51+
if [[ $? -ne 0 ]]; then
52+
echo "Failed to copy ${INPUT_DIR}/${f} to ${OUTPUT_DIR}"
53+
exit 1
54+
fi
55+
done
56+
57+
az version
58+
# Install confcom extension, az is originally available in GitHub workflow environment
59+
az extension add --name confcom
60+
if [[ $? -ne 0 ]]; then
61+
echo "Failed to install Azure confcom extension"
62+
exit 1
63+
fi
64+
65+
# Required by az confcom
66+
sudo usermod -aG docker ${USER}
67+
if [[ $? -ne 0 ]]; then
68+
echo "Failed to add current user to docker group"
69+
exit 1
70+
fi
71+
72+
# Generate operator template
73+
sed -i "s#IMAGE_PLACEHOLDER#${IMAGE}#g" ${OUTPUT_DIR}/operator.json && \
74+
sed -i "s#IMAGE_VERSION_PLACEHOLDER#${IMAGE_VERSION}#g" ${OUTPUT_DIR}/operator.json
75+
if [[ $? -ne 0 ]]; then
76+
echo "Failed to pre-process operator template file"
77+
exit 1
78+
fi
79+
80+
# Export the policy, update it to turn off allow_environment_variable_dropping, and then insert it into the template
81+
# note that the EnclaveId is generated by generate.py on the raw policy, not the base64 version
82+
POLICY_DIGEST_FILE=azure-cc-operator-digest-$VERSION_NUMBER.txt
83+
az confcom acipolicygen --approve-wildcards --template-file ${OUTPUT_DIR}/operator.json --print-policy > ${INPUT_DIR}/policy.base64
84+
base64 -di < ${INPUT_DIR}/policy.base64 > ${INPUT_DIR}/generated.rego
85+
sed -i "s#allow_environment_variable_dropping := true#allow_environment_variable_dropping := false#g" ${INPUT_DIR}/generated.rego
86+
base64 -w0 < ${INPUT_DIR}/generated.rego > ${INPUT_DIR}/generated.rego.base64
87+
python3 ${SCRIPT_DIR}/generate.py ${INPUT_DIR}/generated.rego > ${MANIFEST_DIR}/${POLICY_DIGEST_FILE}
88+
89+
cp ${OUTPUT_DIR}/operator.json ${INPUT_DIR}/source.json
90+
jq --arg policy "$(cat ${INPUT_DIR}/generated.rego.base64)" '.resources[].properties.confidentialComputeProperties.ccePolicy = $policy' ${INPUT_DIR}/source.json > ${OUTPUT_DIR}/operator.json
91+
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: operator-deployment
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app.kubernetes.io/name: operator
10+
template:
11+
metadata:
12+
labels:
13+
app.kubernetes.io/name: operator
14+
annotations:
15+
microsoft.containerinstance.virtualnode.ccepolicy: ''
16+
microsoft.containerinstance.virtualnode.identity: /subscriptions/63e97a70-d825-4b08-af6d-c0d8ad98bed3/resourcegroups/kat-vn-aks/providers/Microsoft.ManagedIdentity/userAssignedIdentities/kat-vn-aks-opr-id
17+
microsoft.containerinstance.virtualnode.injectdns: "false"
18+
spec:
19+
containers:
20+
- image: "mcr.microsoft.com/aci/skr:2.7"
21+
imagePullPolicy: Always
22+
name: skr
23+
resources:
24+
limits:
25+
cpu: 2250m
26+
memory: 2256Mi
27+
requests:
28+
cpu: 100m
29+
memory: 512Mi
30+
env:
31+
- name: Port
32+
value: "9000"
33+
volumeMounts:
34+
- mountPath: /opt/confidential-containers/share/kata-containers/reference-info-base64
35+
name: endorsement-location
36+
command:
37+
- /skr.sh
38+
- name: uid2-operator
39+
image: "ghcr.io/iabtechlab/uid2-operator:5.47.71-alpha-215-SNAPSHOT-azure-cc"
40+
resources:
41+
limits:
42+
memory: "8Gi"
43+
imagePullPolicy: Always
44+
securityContext:
45+
runAsUser: 1000
46+
env:
47+
- name: VAULT_NAME
48+
value: kat-vn-aks-vault
49+
- name: OPERATOR_KEY_SECRET_NAME
50+
value: kat-vn-aks-opr-key-name
51+
- name: DEPLOYMENT_ENVIRONMENT
52+
value: integ
53+
ports:
54+
- containerPort: 8080
55+
protocol: TCP
56+
- name: prometheus
57+
containerPort: 9080
58+
protocol: TCP
59+
readinessProbe:
60+
failureThreshold: 3
61+
httpGet:
62+
path: /ops/healthcheck
63+
port: 8080
64+
scheme: HTTP
65+
initialDelaySeconds: 30
66+
periodSeconds: 10
67+
successThreshold: 1
68+
timeoutSeconds: 1
69+
volumes:
70+
- name: endorsement-location
71+
hostPath:
72+
path: /opt/confidential-containers/share/kata-containers/reference-info-base64
73+
nodeSelector:
74+
virtualization: virtualnode2
75+
tolerations:
76+
- effect: NoSchedule
77+
key: virtual-kubelet.io/provider
78+
operator: Exists
79+
---
80+
apiVersion: v1
81+
kind: Service
82+
metadata:
83+
name: operator-svc
84+
spec:
85+
type: LoadBalancer
86+
selector:
87+
app.kubernetes.io/name: operator
88+
ports:
89+
- protocol: TCP
90+
port: 80
91+
targetPort: 8080

0 commit comments

Comments
 (0)