Skip to content

Commit b846ae2

Browse files
authored
Merge pull request #446 from beraldoleal/release-1.7-v2
Sync release-1.7 with devel
2 parents 8bcea2e + 57a7517 commit b846ae2

File tree

13 files changed

+255
-1435
lines changed

13 files changed

+255
-1435
lines changed

PROJECT

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repo: github.com/openshift/sandboxed-containers-operator
1313
resources:
1414
- group: confidentialcontainers
1515
kind: PeerPodConfig
16-
path: github.com/confidential-containers/cloud-api-adaptor/peerpodconfig-ctrl/api/v1alpha1
16+
path: github.com/confidential-containers/cloud-api-adaptor/src/peerpodconfig-ctrl/api/v1alpha1
1717
version: v1alpha1
1818
- controller: true
1919
domain: kataconfiguration.openshift.io
@@ -30,7 +30,7 @@ resources:
3030
controller: true
3131
domain: confidentialcontainers.org
3232
kind: PeerPod
33-
path: github.com/confidential-containers/cloud-api-adaptor/peerpod-ctrl/api/v1alpha1
33+
path: github.com/confidential-containers/cloud-api-adaptor/src/peerpod-ctrl/api/v1alpha1
3434
version: v1alpha1
3535
- controller: true
3636
group: core

config/peerpods/credentials-requests/credentials_request_aws.yaml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,31 @@ spec:
1010
providerSpec:
1111
apiVersion: cloudcredential.openshift.io/v1
1212
kind: AWSProviderSpec
13-
statementEntries: # limit permissions
13+
statementEntries:
1414
- effect: Allow
15-
action:
16-
- "*"
1715
resource: "*"
16+
action:
17+
- "ec2:*"
18+
# By default we allow all ec2 actions to prevent dysfunctioning for untested configurations.
19+
# The following actions were extracted from AWS CloudTrail Event History,
20+
# filtered based on access key, for peer-pod execution with default configuration.
21+
# use it to restrict the requested permissions.
22+
#- ec2:AuthorizeSecurityGroupIngress
23+
#- ec2:CreateDefaultVpc
24+
#- ec2:CreateImage
25+
#- ec2:CreateKeyPair
26+
#- ec2:CreateTags
27+
#- ec2:CreateSecurityGroup
28+
#- ec2:DeleteKeyPair
29+
#- ec2:DeleteSecurityGroup
30+
#- ec2:DescribeImages
31+
#- ec2:DescribeInstances
32+
#- ec2:DescribeInstanceTypes
33+
#- ec2:DescribeRegions
34+
#- ec2:DescribeSecurityGroups
35+
#- ec2:DescribeSubnets
36+
#- ec2:DescribeVolumes
37+
#- ec2:DescribeVpcs
38+
#- ec2:RunInstances
39+
#- ec2:StopInstances
40+
#- ec2:TerminateInstances

config/peerpods/credentials-requests/credentials_request_azure.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ spec:
1010
providerSpec:
1111
apiVersion: cloudcredential.openshift.io/v1
1212
kind: AzureProviderSpec
13-
roleBindings: # limit
14-
- role: Contributor
13+
roleBindings:
14+
- role: Reader
15+
- role: Virtual Machine Contributor
16+
- role: Network Contributor

config/peerpods/peerpodssecret.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@ stringData:
1010
#LIBVIRT_NET: "default
1111
#LIBVIRT_POOL: "default"
1212
#REDHAT_OFFLINE_TOKEN: "" #Required to download rhel base image : Download token from https://access.redhat.com/management/api
13-
13+
#HOST_KEY_CERTS: "" #Download the certificate from https://www.ibm.com/support/resourcelink/api/content/public/host-key-documents.html and make sure the certficate lines are aligned
14+
# Example:
15+
# HOST_KEY_CERTS: |
16+
# -----BEGIN CERTIFICATE-----
17+
# xxx
18+
# xxx
19+
# -----END CERTIFICATE-----

config/peerpods/podvm/lib.sh

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,20 +208,36 @@ function prepare_source_code() {
208208
# links must be relative
209209
if [[ "${AGENT_POLICY}" ]]; then
210210
echo "Custom agent policy is being set through the AGENT_POLICY value"
211-
echo ${AGENT_POLICY} | base64 -d > "${podvm_dir}"/files/etc/kata-opa/custom.rego
212-
if [[ $? == 0 ]] && grep -q "agent_policy" "${podvm_dir}"/files/etc/kata-opa/custom.rego; then # checks policy validity
213-
ln -sf custom.rego "${podvm_dir}"/files/etc/kata-opa/default-policy.rego
211+
echo "${AGENT_POLICY}" | base64 -d >"${podvm_dir}"/files/etc/kata-opa/custom.rego
212+
return_code=$?
213+
if [[ "$return_code" == 0 ]] && grep -q "agent_policy" "${podvm_dir}"/files/etc/kata-opa/custom.rego; then # checks policy validity
214+
ln -sf custom.rego "${podvm_dir}"/files/etc/kata-opa/default-policy.rego
214215
else
215216
error_exit "Invalid AGENT_POLICY value set, expected base64 encoded valid agent policy, got: \"${AGENT_POLICY}\""
216-
fi
217+
fi
217218
elif [[ "$CONFIDENTIAL_COMPUTE_ENABLED" == "yes" ]]; then
218219
echo "Setting custom agent policy to CoCo's recommended policy"
219220
sed 's/default ReadStreamRequest := true/default ReadStreamRequest := false/;
220221
s/default ExecProcessRequest := true/default ExecProcessRequest := false/' \
221-
"${podvm_dir}"/files/etc/kata-opa/default-policy.rego > "${podvm_dir}"/files/etc/kata-opa/coco-default-policy.rego
222+
"${podvm_dir}"/files/etc/kata-opa/default-policy.rego >"${podvm_dir}"/files/etc/kata-opa/coco-default-policy.rego
222223
ln -sf coco-default-policy.rego "${podvm_dir}"/files/etc/kata-opa/default-policy.rego
223224
fi
224225
echo "~~~ Current Agent Policy ~~~" && cat "${podvm_dir}"/files/etc/kata-opa/default-policy.rego
226+
227+
# Fix disk mounts for CoCo
228+
if [[ "$CONFIDENTIAL_COMPUTE_ENABLED" == "yes" ]]; then
229+
create_overlay_mount_unit
230+
fi
231+
232+
# Validate and copy HKD for IBM Z Secure Enablement
233+
if [[ "$SE_BOOT" == "true" ]]; then
234+
if [[ -z "$HOST_KEY_CERTS" ]]; then
235+
error_exit "Error: HKD is not present."
236+
else
237+
echo "$HOST_KEY_CERTS" >> "${podvm_dir}/files/HKD.crt"
238+
fi
239+
fi
240+
225241
}
226242

227243
# Download and extract pause container image
@@ -267,6 +283,36 @@ function download_and_extract_pause_image() {
267283

268284
}
269285

286+
# Function to create overlay mount unit in the podvm files
287+
# this ensures rw (overlay) layer for the container images are in memory (encrypted)
288+
function create_overlay_mount_unit() {
289+
# The actual mount point is /run/kata-containers/image/overlay
290+
local unit_name="run-kata\\x2dcontainers-image-overlay.mount"
291+
local unit_path="${podvm_dir}/files/etc/systemd/system/${unit_name}"
292+
293+
cat <<EOF >"${unit_path}"
294+
[Unit]
295+
Description=Mount unit for /run/kata-containers/image/overlay
296+
Before=kata-agent.service
297+
298+
[Mount]
299+
What=tmpfs
300+
Where=/run/kata-containers/image/overlay
301+
Type=tmpfs
302+
303+
[Install]
304+
WantedBy=multi-user.target
305+
EOF
306+
307+
echo "Mount unit created at ${unit_name}"
308+
309+
# Enable the mount unit by creating a symlink
310+
# This syntax works to create the symlink to the unit file in ${podvm_dir}/files/etc/systemd/system
311+
ln -sf ../"${unit_name}" "${podvm_dir}/files/etc/systemd/system/multi-user.target.wants/${unit_name}" ||
312+
error_exit "Failed to enable the overlay mount unit"
313+
314+
}
315+
270316
# Global variables
271317

272318
# Set global variable for the source code directory

config/peerpods/podvm/libvirt-podvm-image-cm.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ data:
2121
# Libvirt specific
2222
ORG_ID: ""
2323
ACTIVATION_KEY: ""
24-
BASE_OS_VERSION: "9.2"
24+
BASE_OS_VERSION: "9.4"
25+
26+
# To Enable SE for IBM Z
27+
SE_BOOT: "true"
28+

config/peerpods/podvm/libvirt-podvm-image-handler.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
# Create image (-c)
99
# Delete image (-C)
1010

11-
set -x
1211
# include common functions from lib.sh
1312
# shellcheck source=/dev/null
1413
# The directory is where libvirt-podvm-image-handler.sh is located
@@ -73,6 +72,15 @@ function create_libvirt_image() {
7372
# Function to dowload the rhel base image
7473

7574
function download_rhel_kvm_guest_qcow2() {
75+
#Validate RHEL version for IBM Z Secure Enablement
76+
if [ "$SE_BOOT" == "true" ]; then
77+
version=$(echo $BASE_OS_VERSION | awk -F "." '{ print $1 }')
78+
release=$(echo $BASE_OS_VERSION | awk -F "." '{ print $2 }')
79+
if [[ "$version" -lt 9 || ("$version" -eq 9 && "$release" -lt 4) ]]; then
80+
error_exit "Libvirt Secure Execution supports RHEL OS version 9.4 or above"
81+
fi
82+
fi
83+
7684
ARCH=$(uname -m)
7785
export ARCH
7886

config/peerpods/podvm/osc-podvm-create-job.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ spec:
5757
- name: payload
5858
mountPath: /payload
5959
- name: regauth
60-
mountPath: /tmp/regauth
60+
mountPath: /tmp/regauth
6161
- name: ssh-key-secret
6262
mountPath: "/root/.ssh/"
6363
readOnly: true
64-
optional: true
6564
volumes:
6665
- name: payload
6766
emptyDir: {}
@@ -75,4 +74,5 @@ spec:
7574
- key: id_rsa
7675
path: "id_rsa"
7776
defaultMode: 0400
77+
optional: true
7878
restartPolicy: Never

config/peerpods/podvm/osc-podvm-delete-job.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ spec:
4949
- name: ssh-key-secret
5050
mountPath: "/root/.ssh/"
5151
readOnly: true
52-
optional: true
5352
volumes:
5453
- name: ssh-key-secret
5554
secret:
@@ -58,5 +57,6 @@ spec:
5857
- key: id_rsa
5958
path: "id_rsa"
6059
defaultMode: 0400
60+
optional: true
6161

6262
restartPolicy: Never

controllers/openshift_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"reflect"
2525
"time"
2626

27-
"github.com/confidential-containers/cloud-api-adaptor/peerpodconfig-ctrl/api/v1alpha1"
27+
"github.com/confidential-containers/cloud-api-adaptor/src/peerpodconfig-ctrl/api/v1alpha1"
2828

2929
appsv1 "k8s.io/api/apps/v1"
3030

0 commit comments

Comments
 (0)