Prepare the contract¶
Ensure necessary environment variables are set¶
-
Go to a command prompt on your prep system
-
You should have each of these environment variables set on your prep system:
echo LAB_WORKDIR is ${LAB_WORKDIR} echo LAB_TAR is ${LAB_TAR} echo LOG_INGESTION_KEY is ${LOG_INGESTION_KEY} echo LOG_HOSTNAME is ${LOG_HOSTNAME}
If any of the above commands do not display a value after the is then revisit the section on setting environment variables.
Make the directory hierarchy for Lab 1¶
-
Make a fresh directory structure and change in to it:
mkdir -p ${LAB_WORKDIR}/lab1/play && cd ${LAB_WORKDIR}/lab1
Create a Pod descriptor to specify the application workload¶
-
Switch to the directory that will hold a Pod descriptor:
cd play
-
Create the Pod descriptor::
cat << EOF > play.yml play: resources: - apiVersion: v1 kind: Pod metadata: name: busybox spec: containers: - name: main image: docker.io/library/busybox@sha256:3614ca5eacf0a3a1bcc361c939202a974b4902b9334ff36eb29ffe9011aaad83 command: ["/bin/sh", "-c"] args: - mkdir -p /data/cloudlabs ; env | tee -a /data/cloudlabs/env.out ; cat /data/cloudlabs/env.out ; head -20 /data/cloudlabs/env.out ; head -20 /data/cloudlabs/greetings.out ; tail -20 /data/cloudlabs/greetings.out ; while true ; do echo Hi \${name:-World} the time is \$(date) | tee -a /data/cloudlabs/greetings.out ; sleep \${interval:-60} ; done envFrom: - configMapRef: name: contract.config.map optional: false volumeMounts: - mountPath: /data name: data-vol readOnly: false restartPolicy: Never volumes: - hostPath: path: /mnt/data type: Directory name: data-vol EOF
-
Display the file's content.
cat play.yml
Create the contract¶
-
Change to the directory one level higher than your current location (and display it):
cd .. && pwd
-
Create the contract.
cat << EOF > user_data.yaml env: | type: env logging: logDNA: hostname: ${LOG_HOSTNAME} ingestionKey: ${LOG_INGESTION_KEY} port: 6514 volumes: data: seed: seed-supplied-by-env-persona env: name: Lab 1 Student interval: "30" workload: | type: workload volumes: data: filesystem: ext4 mount: /mnt/data seed: seed-supplied-by-workload-persona $(cat play/play.yml) EOF
-
Display your contract data. Keep your terminal session handy- later on in the next section you will be directed to copy these contents into the IBM Cloud Web UI.
cat user_data.yaml
Proceed to the next section to create your Hyper Protect Virtual Servers for IBM Cloud VPC instance.
Created: June 2, 2023