Skip to content

Commit 2598300

Browse files
authored
Merge pull request #89 from spectrocloud/preloaded-content
docs: steps for adding preloaded content in custom image building
2 parents f779edc + ee1a481 commit 2598300

File tree

3 files changed

+88
-44
lines changed

3 files changed

+88
-44
lines changed

examples/custom-image/README.md

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,62 @@ This script automates the creation of a custom image on a public cloud provider
55
## Prerequisites
66

77
1. **Dependencies**
8+
89
- Bash (Unix/Linux environment)
910
- Packer CLI (https://developer.hashicorp.com/packer/install?product_intent=packer)
1011

1112
2. **Access and Credentials**
13+
1214
- Ensure valid credentials for your target cloud provider.
1315
- For AWS, configure the `aws_access_key` and `aws_secret_key` in the configuration file i.e. custom-image-config.
1416
- Permissions to create and manage images for the chosen cloud provider.
1517

1618
3. **Configuration File**
17-
- **Global Configuration (`custom-image-config`)**:
19+
- **Global Configuration (`custom-image-config`)**:
1820
Contains details about the cloud provider's credentials.
1921
- **Cloud-Specific Configuration (`<cloud-provider>/<os-version>.json`)**:
2022
Specifies the instance details for the cloud provider.
2123

2224
## Usage
2325

2426
1. Prepare the Configuration Files:
25-
Create the custom-image-config file in the project root directory with the required credentials.
26-
Add the appropriate cloud-specific configuration file in the <cloud-provider>/ directory
27+
Create the custom-image-config file in the project root directory with the required credentials.
28+
Add the appropriate cloud-specific configuration file in the <cloud-provider>/ directory
2729

2830
2. Run the Build Script: Execute the build-custom-image.sh script with the desired cloud provider:
29-
```bash
30-
cd examples/custom-image
31-
./build-custom-image.sh <cloud provider>
3231

33-
eg: ./build-custom-image.sh aws
32+
```bash
33+
cd examples/custom-image
34+
./build-custom-image.sh <cloud provider>
35+
36+
eg: ./build-custom-image.sh aws
37+
```
38+
39+
## Adding default userdata
40+
41+
1. Create `user-data` file in the `files` directory.
42+
2. An example of `user-data` file is as follows:
43+
44+
```yaml
45+
#cloud-config
46+
stylus:
47+
path: /var/lib/spectro
48+
installationMode: airgap
49+
```
50+
51+
Refer to [Palette Agent Parameters Documentation](https://docs.spectrocloud.com/clusters/edge/edge-configuration/installer-reference/#palette-agent-parameters) for more details.
52+
53+
## Adding preloaded content in your image
54+
55+
1. Add your content bundle in the `files` directory.
56+
2. In your userdata, add following stages to copy the content bundle to the desired location. Suppose your content bundle is named as content.zst
57+
58+
```yaml
59+
#cloud-config
60+
stages:
61+
after-install:
62+
- name: Extract content bundle
63+
if: "[ -f /tmp/files/content.zst ]"
64+
commands:
65+
- $STYLUS_ROOT/opt/spectrocloud/bin/palette-agent content-extract --source /tmp/files/content.zst
66+
```
Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
11
{
2-
"builders": [{
3-
"type": "amazon-ebs",
4-
"region": "{{ user `aws_region` }}",
5-
"source_ami": "{{user `source_ami`}}",
6-
"instance_type": "{{user `builder_instance_type`}}",
7-
"ssh_username": "{{user `ssh_username`}}",
8-
"ami_name": "{{user `ami_name`}}",
9-
"source_ami_filter": {
10-
"filters": {
11-
"architecture": "x86_64",
12-
"name": "{{user `ami_filter_name`}}",
13-
"root-device-type": "ebs",
14-
"virtualization-type": "hvm"
2+
"builders": [
3+
{
4+
"type": "amazon-ebs",
5+
"region": "{{ user `aws_region` }}",
6+
"source_ami": "{{user `source_ami`}}",
7+
"instance_type": "{{user `builder_instance_type`}}",
8+
"ssh_username": "{{user `ssh_username`}}",
9+
"ami_name": "{{user `ami_name`}}",
10+
"source_ami_filter": {
11+
"filters": {
12+
"architecture": "x86_64",
13+
"name": "{{user `ami_filter_name`}}",
14+
"root-device-type": "ebs",
15+
"virtualization-type": "hvm"
16+
},
17+
"most_recent": true,
18+
"owners": "{{user `ami_filter_owners`}}"
1519
},
16-
"most_recent": true,
17-
"owners": "{{user `ami_filter_owners`}}"
18-
},
19-
"vpc_id": "{{ user `vpc_id` }}",
20-
"subnet_id": "{{ user `subnet_id` }}"
21-
}],
20+
"vpc_id": "{{ user `vpc_id` }}",
21+
"subnet_id": "{{ user `subnet_id` }}"
22+
}
23+
],
2224

23-
"provisioners": [
24-
{
25-
"type": "shell",
26-
"inline": [
27-
"set -e",
28-
"sudo apt update -y || (echo 'APT Update Failed'; exit 1)",
29-
"sudo apt install -y bash systemd rsync rsyslog jq zstd conntrack systemd-timesyncd || (echo 'APT Install Failed'; exit 1)"
30-
]
31-
},
32-
{
33-
"type": "shell",
34-
"inline": [
35-
"curl -fsSL -o /tmp/palette-agent-install.sh https://github.com/spectrocloud/agent-mode/releases/latest/download/palette-agent-install.sh",
36-
"chmod +x /tmp/palette-agent-install.sh",
37-
"sudo /tmp/palette-agent-install.sh"
38-
]
39-
}
40-
]
25+
"provisioners": [
26+
{
27+
"type": "shell",
28+
"inline": [
29+
"set -e",
30+
"sudo apt update -y || (echo 'APT Update Failed'; exit 1)",
31+
"sudo apt install -y bash systemd rsync rsyslog jq zstd conntrack systemd-timesyncd || (echo 'APT Install Failed'; exit 1)"
32+
]
33+
},
34+
{
35+
"type": "file",
36+
"source": "files",
37+
"destination": "/tmp"
38+
},
39+
{
40+
"type": "shell",
41+
"inline": [
42+
"curl -fsSL -o /tmp/palette-agent-install.sh https://github.com/spectrocloud/agent-mode/releases/latest/download/palette-agent-install.sh",
43+
"chmod +x /tmp/palette-agent-install.sh",
44+
"sudo -E USERDATA=/tmp/files/user-data /tmp/palette-agent-install.sh"
45+
]
46+
}
47+
]
4148
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#cloud-config
2+
stylus:
3+
path: /var/lib/spectro
4+
installationMode: airgap

0 commit comments

Comments
 (0)