Skip to content

Instantly share code, notes, and snippets.

@dennisseah
Last active January 19, 2020 21:32
Show Gist options
  • Save dennisseah/85f5e1334d3d31767a8a59532321b2e5 to your computer and use it in GitHub Desktop.
Save dennisseah/85f5e1334d3d31767a8a59532321b2e5 to your computer and use it in GitHub Desktop.
Initial SPK Setup on mac

Initial SPK Setup on mac

Register for a Azure DevOps Account

Create Project, Personal Access Token and GIT Repositories

You will get an confirmation email. Go to the website

Create a project in Azure DevOps and TFS

  1. add ssh key for git clone, pull and push
ssh-keygen -C "<alias>@microsoft.com"
cat ~/.ssh/id_rsa.pub
  1. create a project BedrockSPK.
  2. create a Personal Access Token, PAT. Grant Full Access to the token until we figure out the necessary privileges. Remember to copy the secret associated with the token.
  3. create 3 GIT repos, Manifests, HighLevelDefinition and Application

Execute these

export org=<your microsoft alias> e.g. mine is veseah
export project=BedrockSPK
export PAT=<secret of PAT>

Create a docker register and service principal

https://ms.portal.azure.com/

  • Create a docker register, I have it as bedrockSPK
  • Create a service principal
az ad sp create-for-rbac --role contributor --scopes /subscriptions/<sub-id>

execute

export ACR_NAME=bedrockSPK
export SP_APP_ID=<SP App ID>
export SP_TENANT=<SP Tenant>
export SP_PASS=<SP Secret>

Download SPK

here

  • Download spk-macos
  • copy it to a execute path that is accessible
  • rename it to spk
  • chmod +x spk

Initialize SPK

copy below to a temporary file. temp.yaml

azure_devops:
  access_token: @@PAT@@
  hld_repository: 'https://dev.azure.com/@@org@@/@@project@@/_git/HighLevelDefinition'
  manifest_repository: 'https://dev.azure.com/@@org@@/@@project@@/_git/Manifests'
  infra_repository: >-
    https://dev.azure.com/naros32/bedrock_testing_phase2/_git/spk-testing-private-azdo
  org: @@org@@
  project: @@project@@
infra:
  terraform: v0.12.6
  helm: v2.14.3
  git: 2.17.1
  az: 2.0.71
introspection:
  dashboard:
    image: 'samiyaakhtar/spektate:prod'
    name: spektate
  azure:
    account_name: storage-account-name
    table_name: storage-account-table-name
    partition_key: storage-account-table-partition-key
    key: storage-access-key
    source_repo_access_token: source_repo_access_token
    service_principal_id: service-principal-id
    service_principal_secret: service-principal-secret
    subscription_id: subscription-id
    tenant_id: tenant-id
    resource_group: resource-group-name
key_vault_name: null

execute

sed  "s/@@org@@/${org}/g; s/@@project@@/${project}/g; s/@@PAT@@/${PAT}/g" temp.yaml > /tmp/config.yaml
spk init -f /tmp/config.yaml

Setup

git clone git@ssh.dev.azure.com:v3/${org}/${project}/Manifests
cd Manifests
touch README.md
echo "This is the Flux Manifest Repository." >> README.md
git add -A
git commit -m "Initializing Materialized Manifests repository with a README."
git push -u origin --all

cd ..
git clone git@ssh.dev.azure.com:v3/${org}/${project}/HighLevelDefinition
cd HighLevelDefinition
spk hld init
git add -A
git commit -m "Initializing HLD repository with the cloud-native stack."
git push -u origin --all
spk hld install-manifest-pipeline

cd ..
git clone git@ssh.dev.azure.com:v3/${org}/${project}/Application
cd Application
spk project init
git add -A
git commit -m "Initializing application repository."
git push -u origin --all

export VARIABLE_GROUP_NAME=BedrockSPKSecrets

spk project create-variable-group $VARIABLE_GROUP_NAME -r $ACR_NAME -u $SP_APP_ID -t $SP_TENANT -p $SP_PASS
git add -A
git commit -m "Adding Project Variable Group."
git push -u origin --all
spk project install-lifecycle-pipeline

export SERVICE_NAME=ServiceA
spk service create $SERVICE_NAME
git add -A
git commit -m "Adding $SERVICE_NAME to the repository."
git push -u origin --all

spk service install-build-pipeline $SERVICE_NAME

Teardown

  • Remove azure devops project, BedrockSPK
  • remove the git folders on your laptop, rm -fr Application/ HighLevelDefinition/ Manifests/

Repeat

  1. Do Create Project, Personal Access Token and GIT Repositories, you can skip the export statements
  2. Do Setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment