Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7efccce
Adding devcontainer up unit test
KevinDMack Mar 14, 2025
b89cab3
Adding changes
KevinDMack Mar 14, 2025
4bf35a1
Adding installation
KevinDMack Mar 14, 2025
b1bc5bf
Updating reference
KevinDMack Mar 14, 2025
3f964bf
Adding main
KevinDMack Mar 14, 2025
5d8bece
Fixing action name
KevinDMack Mar 14, 2025
0494c7e
Fixing job name
KevinDMack Mar 14, 2025
4730943
Updating for tag
KevinDMack Mar 14, 2025
6024e1b
Adding devcontainer exec test
KevinDMack Mar 14, 2025
c6f10b1
adding to test runner
KevinDMack Mar 14, 2025
3afa029
Adding new container name
KevinDMack Mar 14, 2025
9ffb410
Adding validating step
KevinDMack Mar 14, 2025
8458a5f
Updating for container name
KevinDMack Mar 14, 2025
cbaf9cd
Adding name
KevinDMack Mar 14, 2025
ebc5f9e
Updating Validate step
KevinDMack Mar 14, 2025
7e06ad9
Flipping to devcontainer cli for execution
KevinDMack Mar 14, 2025
5aff93e
Fixing command
KevinDMack Mar 14, 2025
de3be89
Adding workspace folder
KevinDMack Mar 14, 2025
017c6cf
Rearrange items
KevinDMack Mar 14, 2025
acdfb0c
Updating signature
KevinDMack Mar 14, 2025
de21146
Restructing command
KevinDMack Mar 17, 2025
234c87a
Adding output steps
KevinDMack Mar 18, 2025
82a34eb
Updating for double quotes
KevinDMack Mar 18, 2025
0f8b197
Updating to remove extra quote
KevinDMack Mar 18, 2025
db3d53b
Adding logic
KevinDMack Mar 18, 2025
7641b0b
Updating reference
KevinDMack Mar 18, 2025
b09cafa
Updating script
KevinDMack Mar 18, 2025
3f6c89b
Fixing reference
KevinDMack Mar 18, 2025
4a44701
Updating with demo
KevinDMack Apr 8, 2025
1a504a6
Adding tasks and extensions
KevinDMack Jun 5, 2025
883ebbb
Adding install packer script
KevinDMack Jun 5, 2025
7303719
Adding linux vm packer images for kubernetes jumpbox
KevinDMack Jun 5, 2025
d402fdb
Updating readme
KevinDMack Jul 1, 2025
e6cc3cd
Updating parameters for more control
KevinDMack Jul 1, 2025
140d849
Updating readme
KevinDMack Jul 1, 2025
88b3128
Updating for packer install
KevinDMack Jul 1, 2025
6513ff0
Merge branch 'main' into 21-devcontainer-actions
KevinDMack Jul 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"features": {
"ghcr.io/devcontainers/features/azure-cli:1": {},
"ghcr.io/devcontainers-extra/features/devcontainers-cli:1": {}
}
},

// Run script after container is created
"postCreateCommand": "chmod +x ./scripts/install-packer.sh && ./scripts/install-packer.sh"

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"hashicorp.hcl"
]
}
23 changes: 23 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Install Packer",
"type": "shell",
"command": "./scripts/install-packer.sh",
"args": [],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "shared",
"close": false
},
"problemMatcher": []
}
]
}
46 changes: 44 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The key elements in this repo are:
- **Bicep Modules:** These bicep modules provide "lego bricks" for assembling your infrastructure-as-code" deployments and are built to meet the specification of Government customers and impact levels.
- **Developer Scripts:** These scripts are designed to include common operations that are designed to provide "easy-buttons" to prevent having to lookup what each of these steps is, and how they work.
- **Github Composite Actions:** These are composite actions designed specifically to be atomic and reusable in a variety of situations. The intention being that these are common steps to prevent technical debt, improve quality, and increase stability by leveraging a single code instance.
- **Packer VM Configuration:** These are packer images for specific virtual machines that are designed to support specific use-cases.

## Bicep Modules

Expand Down Expand Up @@ -80,7 +81,6 @@ DEFAULT_TAG_VALUE="" # The value of the tag.
az deployment group create --resource-group $RESOURCE_GROUP_NAME --template-file ./modules/virtual-machine.bicep --parameters vm_name=$VM_NAME subnet_id=$SUBNET_ID data_science_vm_type=$MACHINE_TYPE admin_user_name=$ADMIN_USER_NAME default_tag_name=$DEFAULT_TAG_NAME default_tag_value=$DEFAULT_TAG_VALUE
```


## Developer Scripts

For this repo there are several developer scripts designed to provide support for common operations. They are outlined below:
Expand Down Expand Up @@ -129,4 +129,46 @@ When identifying the "@" value at the end of the line, you have 2 options:

1. You can use "@main" which will always pull the "main" branch version that is available. That does mean that you will always being using the latest, and if the parameter signature changes, it wil fail.
2. You can pin to the "latest" of that action file, by using "@__ACTION_NAME__-latest" (for example: get-agent-details-latest). This is predominantly used for testing.
3. You can pin to a specific version number, by using "@__ACTION_NAME__-__VERSION_NUMBER__" (for example: get-agent-details-1.0.0), this will pin you to a specific release.
3. You can pin to a specific version number, by using "@__ACTION_NAME__-__VERSION_NUMBER__" (for example: get-agent-details-1.0.0), this will pin you to a specific release.

## Packer Virtual Machine Configuration:

This repo contains virtual machine configurations to support new environments that are created. The following are the key virtual machine configuration files in this repo:

- **[kubernetes-linux-jumpbox.pkr.hcl](./vm-images/kubernetes-linux-jumpbox.pkr.hcl): This machine provides a jumpbox for accessing and working with kubernetes clusters.

### Build packer vm images:

To build a VM image in your Azure subscription using the `./vm-images/kubernetes-linux-jumpbox.pkr.hcl` file, follow these steps:

1. **Install Packer**
Make sure you have [Packer](https://developer.hashicorp.com/packer/install) installed on your machine. You can run this script to install it or use the repo task by hitting F1.

```bash
bash ./scripts/install-packer.sh
```

2. **Authenticate with Azure**
Ensure you are logged in to Azure CLI and have the necessary permissions:
```bash
az cloud set --name AzureUSGovernment
az login --use-device-code
az account set --subscription "<your-subscription-id>"
```

3. **Validate the Packer Template**
Run the following command to validate your Packer template:
```bash
packer validate ./vm-images/kubernetes-linux-jumpbox.pkr.hcl
```

4. **Build the Image**
Execute the build command:
```bash
packer build -var "subscription_id=<your-subscription-id>" -var "location=<your-location>" ./vm-images/kubernetes-linux-jumpbox.pkr.hcl
```

5. **Locate the Image in Azure**
After the build completes, the image will be available in the resource group and location specified in your Packer template.

> For more details, see the [Packer Azure Builder documentation](https://developer.hashicorp.com/packer/plugins/builders/azure).
21 changes: 21 additions & 0 deletions bicep-sample/sample-app-service.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
param prefix string
param location string = 'usgovvirginia'
param appServicePlanSku string = 'P1v2'

resource appService 'Microsoft.Web/sites@2022-03-01' = {
name: '${prefix}-app'
location: location
properties: {
serverFarmId: appServicePlan.id
}
}

resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
name: '${prefix}-app-plan'
location: location
sku: {
name: appServicePlanSku
tier: 'PremiumV2'
}
kind: 'app'
}
40 changes: 40 additions & 0 deletions bicep-sample/sample-deployment.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
targetScope = 'subscription'
@description('Prefix for the resource names')
param prefix string

@description('Location for the resource group')
param location string = 'usgovvirginia'

@description('SKU for the App Service Plan')
param appServicePlanSku string = 'P1v2'

@description('SKU for the Storage Account')
param storageSku string = 'Standard_LRS'

// Resource Group
resource resourceGroup 'Microsoft.Resources/resourceGroups@2024-11-01' = {
name: '${prefix}-rg'
location: location
}

module appServiceModule 'sample-app-service.bicep' = {
name: 'appServiceModule'
scope: resourceGroup
params: {
prefix: prefix
location: location
appServicePlanSku: appServicePlanSku
}
}
module storageModule 'sample-storage.bicep' = {
name: 'storageModule'
scope: resourceGroup
params: {
prefix: prefix
location: location
storageSku: storageSku
}
}

// Output resource IDs
output resourceGroupId string = resourceGroup.id
12 changes: 12 additions & 0 deletions bicep-sample/sample-storage.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
param prefix string
param location string = 'usgovvirginia'
param storageSku string = 'Standard_LRS'

resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
name: '${prefix}stg'
location: location
sku: {
name: storageSku
}
kind: 'StorageV2'
}
11 changes: 11 additions & 0 deletions scripts/install-packer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e

# Download and add HashiCorp GPG key to the keyring
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg

# Add HashiCorp repository with proper keyring reference
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list

# Update package list and install Packer
sudo apt-get update && sudo apt-get install -y packer
138 changes: 138 additions & 0 deletions vm-images/kubernetes-linux-jumpbox.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
variable "subscription_id" {
type = string
default = ""
description = "Azure Subscription ID"
}

variable "location" {
type = string
default = "usgovvirginia"
description = "Azure region for the image"
}

variable "managed_images_rg_name" {
type = string
default = "packer-vm-images"
description = "Resource group name for the Packer VM images"
}

variable "managed_image_name" {
type = string
default = "ubuntu2404-aks-linux-jumpbox-image"
description = "Name of the managed image to be created by Packer"
}

packer {
required_plugins {
azure = {
version = ">= 1.0.0"
source = "github.com/hashicorp/azure"
}
}
}

source "azure-arm" "ubuntu2404" {
subscription_id = var.subscription_id
cloud_environment_name = "AzureUSGovernmentCloud"
location = var.location

managed_image_resource_group_name = var.managed_images_rg_name
managed_image_name = var.managed_image_name

vm_size = "Standard_DS1_v2"
os_type = "Linux"
image_publisher = "Canonical"
image_offer = "ubuntu-24_04-lts"
image_sku = "server"
image_version = "latest"

azure_tags = {
environment = "image-library"
}

use_azure_cli_auth = true
}

build {
sources = ["source.azure-arm.ubuntu2404"]

provisioner "shell" {
environment_vars = ["DEBIAN_FRONTEND=noninteractive"]
inline = [
"echo 'Running the initial setup upgrade...'",
"sudo apt-get update",
"sudo apt-get upgrade -y"
]
}

provisioner "shell" {
environment_vars = ["DEBIAN_FRONTEND=noninteractive"]
inline = [
"echo 'Installing kubectl...'",
"curl -LO \"https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl\"",
"sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl",
"kubectl version --client"
]
}

provisioner "shell" {
environment_vars = ["DEBIAN_FRONTEND=noninteractive"]
inline = [
"echo 'Install Azure CLI...'",
"curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash"
]
}

provisioner "shell" {
environment_vars = ["DEBIAN_FRONTEND=noninteractive"]
inline = [
"echo 'Installing Helm...'",
"curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3",
"chmod 700 get_helm.sh",
"./get_helm.sh"
]
}

provisioner "shell" {
environment_vars = ["DEBIAN_FRONTEND=noninteractive"]
inline = [
"echo 'Installing k9s...'",
"wget https://github.com/derailed/k9s/releases/download/v0.50.6/k9s_linux_amd64.deb",
"sudo apt install ./k9s_linux_amd64.deb",
"k9s version",
"rm k9s_linux_amd64.deb"
]
}

provisioner "shell" {
environment_vars = ["DEBIAN_FRONTEND=noninteractive"]
inline = [
"echo 'Installing Terraform...'",
"wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg",
"echo \"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main\" | sudo tee /etc/apt/sources.list.d/hashicorp.list",
"sudo apt update && sudo apt install terraform"
]
}

provisioner "shell" {
environment_vars = ["DEBIAN_FRONTEND=noninteractive"]
inline = [
"echo 'Installing RegClient...'",
"curl -L https://github.com/regclient/regclient/releases/latest/download/regctl-linux-amd64 >regctl",
"chmod 755 regctl"
]
}

provisioner "shell" {
environment_vars = ["DEBIAN_FRONTEND=noninteractive"]
inline = [
"echo 'Installing Docker...'",
"sudo apt-get install ca-certificates curl",
"sudo install -m 0755 -d /etc/apt/keyrings",
"sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc",
"sudo chmod a+r /etc/apt/keyrings/docker.asc",
"echo \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo \"$VERSION_CODENAME\") stable\" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null",
"sudo apt-get update"
]
}
}
Loading