-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tutorial for using security enclaves with ConfigMap. (#43)
Signed-off-by: Tomoya.Fujita <tomoya.fujita825@gmail.com>
- Loading branch information
1 parent
464a851
commit 7a04ce1
Showing
7 changed files
with
333 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
### enable debug | ||
#set -exvfC | ||
set -e | ||
|
||
# Directory to process | ||
DIR="$1" | ||
|
||
# Ensure the directory is provided as an argument | ||
if [ -z "$DIR" ]; then | ||
echo "Usage: $0 <directory>" | ||
exit 1 | ||
fi | ||
|
||
# Check if the provided directory exists | ||
if [ ! -d "$DIR" ]; then | ||
echo "Error: Directory '$DIR' does not exist." | ||
exit 1 | ||
fi | ||
|
||
# Find all symbolic links in the directory (not recursively) | ||
find "$DIR" -maxdepth 1 -type l | while read -r symlink; do | ||
# Get the actual file to which the symbolic link points | ||
target_file=$(readlink -f "$symlink") | ||
|
||
# If the target file doesn't exist, warn and skip | ||
if [ ! -e "$target_file" ]; then | ||
echo "Warning: Symbolic link '$symlink' points to a non-existent file." | ||
continue | ||
fi | ||
|
||
# Copy the content of the original file to the location of the symbolic link | ||
cp "$target_file" "$symlink" && \ | ||
echo "Replaced symbolic link '$symlink' with the actual file." || \ | ||
echo "Error: Failed to replace symbolic link '$symlink'." | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: security-env-config | ||
namespace: default | ||
data: | ||
ROS_SECURITY_KEYSTORE: /etc/demo_keystore | ||
ROS_SECURITY_ENABLE: "true" | ||
ROS_SECURITY_STRATEGY: Enforce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: ros2-secured-talker | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: ros2-secured-talker | ||
template: | ||
metadata: | ||
labels: | ||
app: ros2-secured-talker | ||
spec: | ||
containers: | ||
- image: tomoyafujita/ros:rolling | ||
command: ["/bin/bash", "-c"] | ||
# Bind the security environmental variable | ||
envFrom: | ||
- configMapRef: | ||
name: security-env-config | ||
# Start the application with security option | ||
args: ["source /opt/ros/$ROS_DISTRO/setup.bash && ros2 run demo_nodes_cpp talker --ros-args --enclave /talker_listener/talker"] | ||
imagePullPolicy: IfNotPresent | ||
tty: true | ||
name: ros2-secured-talker | ||
# Bind the volume | ||
volumeMounts: | ||
- name: talker-security | ||
mountPath: /etc/demo_keystore/enclaves/talker_listener/talker | ||
# Create volume to bind from ConfigMap | ||
volumes: | ||
- name: talker-security | ||
configMap: | ||
name: talker-enclaves | ||
tolerations: | ||
- key: node-role.kubernetes.io/master | ||
operator: Exists | ||
effect: NoSchedule | ||
- key: node-role.kubernetes.io/control-plane | ||
operator: Exists | ||
effect: NoSchedule | ||
restartPolicy: Always | ||
|
||
--- | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: ros2-secured-listener | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: ros2-secured-listener | ||
template: | ||
metadata: | ||
labels: | ||
app: ros2-secured-listener | ||
spec: | ||
containers: | ||
- image: tomoyafujita/ros:rolling | ||
command: ["/bin/bash", "-c"] | ||
# Bind the security environmental variable | ||
envFrom: | ||
- configMapRef: | ||
name: security-env-config | ||
# Start the application with security option | ||
args: ["source /opt/ros/$ROS_DISTRO/setup.bash && ros2 run demo_nodes_cpp listener --ros-args --enclave /talker_listener/listener"] | ||
imagePullPolicy: IfNotPresent | ||
tty: true | ||
name: ros2-secured-listener | ||
# Bind the volume | ||
volumeMounts: | ||
- name: listener-security | ||
mountPath: /etc/demo_keystore/enclaves/talker_listener/listener | ||
# Create volume to bind from ConfigMap | ||
volumes: | ||
- name: listener-security | ||
configMap: | ||
name: listener-enclaves | ||
tolerations: | ||
- key: node-role.kubernetes.io/master | ||
operator: Exists | ||
effect: NoSchedule | ||
- key: node-role.kubernetes.io/control-plane | ||
operator: Exists | ||
effect: NoSchedule | ||
restartPolicy: Always |