Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Refactor to use 'app' instead of 'client' for service principal
Browse files Browse the repository at this point in the history
  • Loading branch information
ejizba committed Mar 30, 2017
1 parent 5839d44 commit de5596c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
20 changes: 10 additions & 10 deletions quickstart_template/301-jenkins-acr-spinnaker-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ https://github.com/Azure/azure-quickstart-templates/tree/master/301-jenkins-acr-
Command
$0
Arguments
--client_id|-ci [Required] : Service principal client id used to dynamically manage resource in your subscription
--client_key|-ck [Required] : Service principal client key used to dynamically manage resource in your subscription
--app_id|-ai [Required] : Service principal app id used to dynamically manage resource in your subscription
--app_key|-ak [Required] : Service principal app key used to dynamically manage resource in your subscription
--subscription_id|-si [Required] : Subscription Id
--tenant_id|-ti [Required] : Tenant Id
--user_name|-un [Required] : Admin user name for your Spinnaker VM and Kubernetes cluster
Expand Down Expand Up @@ -45,12 +45,12 @@ do
key="$1"
shift
case $key in
--client_id|-ci)
client_id="$1"
--app_id|-ai)
app_id="$1"
shift
;;
--client_key|-ck)
client_key="$1"
--app_key|-ak)
app_key="$1"
shift
;;
--subscription_id|-si)
Expand Down Expand Up @@ -119,8 +119,8 @@ do
esac
done

throw_if_empty --client_id $client_id
throw_if_empty --client_key $client_key
throw_if_empty --app_id $app_id
throw_if_empty --app_key $app_key
throw_if_empty --subscription_id $subscription_id
throw_if_empty --tenant_id $tenant_id
throw_if_empty --user_name $user_name
Expand All @@ -139,7 +139,7 @@ pipeline_registry="$azure_container_registry"
front50_port="8081"

# Configure Spinnaker (do this first because the default InstallSpinnaker.sh script sets up front50 on port 8080 and that might fail if we did Jenkins first)
curl --silent "${artifacts_location}quickstart_template/spinnaker_vm_to_kubernetes.sh${artifacts_location_sas_token}" | sudo bash -s -- -ci "$client_id" -ck "$client_key" -si "$subscription_id" -ti "$tenant_id" -un "$user_name" -rg "$resource_group" -mf "$master_fqdn" -mc "$master_count" -san "$storage_account_name" -sak "$storage_account_key" -acr "$azure_container_registry" -ikp "$include_kubernetes_pipeline" -prg "$pipeline_registry" -prp "$docker_repository" -pp "$pipeline_port" -fp "$front50_port" -al "$artifacts_location" -st "$artifacts_location_sas_token"
curl --silent "${artifacts_location}quickstart_template/spinnaker_vm_to_kubernetes.sh${artifacts_location_sas_token}" | sudo bash -s -- -ai "$app_id" -ak "$app_key" -si "$subscription_id" -ti "$tenant_id" -un "$user_name" -rg "$resource_group" -mf "$master_fqdn" -mc "$master_count" -san "$storage_account_name" -sak "$storage_account_key" -acr "$azure_container_registry" -ikp "$include_kubernetes_pipeline" -prg "$pipeline_registry" -prp "$docker_repository" -pp "$pipeline_port" -fp "$front50_port" -al "$artifacts_location" -st "$artifacts_location_sas_token"

# Configure Jenkins
curl --silent "${artifacts_location}quickstart_template/201-jenkins-to-azure-container-registry.sh${artifacts_location_sas_token}" | sudo bash -s -- -u "$user_name" -g "$git_repository" -r "https://$azure_container_registry" -ru "$client_id" -rp "$client_key" -rr "$docker_repository" -al "$artifacts_location" -st "$artifacts_location_sas_token"
curl --silent "${artifacts_location}quickstart_template/201-jenkins-to-azure-container-registry.sh${artifacts_location_sas_token}" | sudo bash -s -- -u "$user_name" -g "$git_repository" -r "https://$azure_container_registry" -ru "$app_id" -rp "$app_key" -rr "$docker_repository" -al "$artifacts_location" -st "$artifacts_location_sas_token"
22 changes: 11 additions & 11 deletions quickstart_template/spinnaker_vm_to_kubernetes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ https://github.com/Azure/azure-quickstart-templates/tree/master/spinnaker-vm-to-
Command
$0
Arguments
--client_id|-ci [Required] : Service principal client id used to dynamically manage resource in your subscription
--client_key|-ck [Required] : Service principal client key used to dynamically manage resource in your subscription
--app_id|-ai [Required] : Service principal app id used to dynamically manage resource in your subscription
--app_key|-ak [Required] : Service principal app key used to dynamically manage resource in your subscription
--subscription_id|-si [Required] : Subscription Id
--tenant_id|-ti [Required] : Tenant Id
--user_name|-un [Required] : Admin user name for your Spinnaker VM and Kubernetes cluster
Expand Down Expand Up @@ -50,12 +50,12 @@ do
key="$1"
shift
case $key in
--client_id|-ci)
client_id="$1"
--app_id|-ai)
app_id="$1"
shift
;;
--client_key|-ck)
client_key="$1"
--app_key|-ak)
app_key="$1"
shift
;;
--subscription_id|-si)
Expand Down Expand Up @@ -132,8 +132,8 @@ do
esac
done

throw_if_empty --client_id $client_id
throw_if_empty --client_key $client_key
throw_if_empty --app_id $app_id
throw_if_empty --app_key $app_key
throw_if_empty --subscription_id $subscription_id
throw_if_empty --tenant_id $tenant_id
throw_if_empty --user_name $user_name
Expand Down Expand Up @@ -167,7 +167,7 @@ fi

# Login to azure cli using service principal
azure telemetry --disable
azure login --service-principal -u $client_id -p $client_key --tenant $tenant_id
azure login --service-principal -u $app_id -p $app_key --tenant $tenant_id
azure account set $subscription_id

# Copy kube config to this VM
Expand All @@ -182,7 +182,7 @@ else
fi

# Configure Spinnaker to target kubernetes
curl --silent "${artifacts_location}spinnaker/configure_k8s/configure_k8s.sh${artifacts_location_sas_token}" | sudo bash -s -- -rg "$azure_container_registry" -ci "$client_id" -ck "$client_key" -rp "$docker_repository" -al "$artifacts_location" -st "$artifacts_location_sas_token"
curl --silent "${artifacts_location}spinnaker/configure_k8s/configure_k8s.sh${artifacts_location_sas_token}" | sudo bash -s -- -rg "$azure_container_registry" -ai "$app_id" -ak "$app_key" -rp "$docker_repository" -al "$artifacts_location" -st "$artifacts_location_sas_token"

# Install and setup Kubernetes cli for admin user
if !(command -v kubectl >/dev/null); then
Expand Down Expand Up @@ -215,7 +215,7 @@ if (( $include_kubernetes_pipeline )); then
touch "$temp_dir/Dockerfile"
echo -e "FROM scratch\nADD . README" >"$temp_dir/Dockerfile"
# We added the user to the docker group above, but that doesn't take effect until the next login so we still need to use sudo here
sudo docker login "$azure_container_registry" -u "$client_id" -p "$client_key"
sudo docker login "$azure_container_registry" -u "$app_id" -p "$app_key"
sudo docker build $temp_dir --tag "$azure_container_registry/$pipeline_repository"
sudo docker push "$azure_container_registry/$pipeline_repository"
sudo docker rmi "$azure_container_registry/$pipeline_repository"
Expand Down
6 changes: 3 additions & 3 deletions spinnaker/configure_k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ This must be executed on a machine with an existing Spinnaker instance.
| Name | Description |
|---|---|
| --registry<br/>-rg | The Azure Container Registry url, for example 'sample-microsoft.azurecr.io'. |
| --client_id<br/>-ci | The Service Principal client id used to access your registry. |
| --client_key<br/>-ck | The Service Principal client key used to access your registry. |
| --app_id<br/>-ai | The Service Principal app id used to access your registry. |
| --app_key<br/>-ak | The Service Principal app key used to access your registry. |
| --repository<br/>-rp | (optional) The docker repository if targeting a repo from 'index.docker.io'. If targeting an Azure Container Registry, the repository does _not_ need to be explicitly specified. |
| --artifacts_location<br/>-al | (optional) The url for referencing other scripts/artifacts. The default is this github repository. |
| --sas_token<br/>-st | (optional) A sas token needed if the artifacts location is private. |

## Example usage
```bash
./configure_k8s.sh --registry "sample-microsoft.azurecr.io" --client_id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" --client-key "password"
./configure_k8s.sh --registry "sample-microsoft.azurecr.io" --app_id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" --app-key "password"
```

## Questions/Comments? [email protected]
20 changes: 10 additions & 10 deletions spinnaker/configure_k8s/configure_k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Command
Arguments
--registry|-rg [Required]: Registry url
--client_id|-ci [Required]: Service principal client id used to access the registry
--client_key|-ck [Required]: Service principal client key used to access the registry
--app_id|-ai [Required]: Service principal app id used to access the registry
--app_key|-ak [Required]: Service principal app key used to access the registry
--repository|-rp : DockerHub repository to configure
--artifacts_location|-al : Url used to reference other scripts/artifacts.
--sas_token|-st : A sas token needed if the artifacts location is private.
Expand Down Expand Up @@ -41,12 +41,12 @@ do
registry=${registry%"/"}
shift
;;
--client_id|-ci)
client_id="$1"
--app_id|-ai)
app_id="$1"
shift
;;
--client_key|-ck)
client_key="$1"
--app_key|-ak)
app_key="$1"
shift
;;
--repository|-rp)
Expand All @@ -72,8 +72,8 @@ do
done

throw_if_empty --registry $registry
throw_if_empty --client_id $client_id
throw_if_empty --client_key $client_key
throw_if_empty --app_id $app_id
throw_if_empty --app_key $app_key

spinnaker_config_dir="/opt/spinnaker/config/"
clouddriver_config_file="${spinnaker_config_dir}clouddriver-local.yml"
Expand Down Expand Up @@ -107,8 +107,8 @@ dockerRegistry:
EOF

sudo sed -i "s|REPLACE_ACR_REGISTRY|${registry}|" $clouddriver_config_file
sudo sed -i "s|REPLACE_ACR_USERNAME|${client_id}|" $clouddriver_config_file
sudo sed -i "s|REPLACE_ACR_PASSWORD|${client_key}|" $clouddriver_config_file
sudo sed -i "s|REPLACE_ACR_USERNAME|${app_id}|" $clouddriver_config_file
sudo sed -i "s|REPLACE_ACR_PASSWORD|${app_key}|" $clouddriver_config_file

# Replace docker repository in config if specified
if [ -n "$repository" ]; then
Expand Down

0 comments on commit de5596c

Please sign in to comment.