-
Set zone
gcloud config set compute/zone us-east1-d
-
Buat cluster
gcloud container clusters create spinnaker-tutorial \ --machine-type=n1-standard-2
-
Bust service account
gcloud iam service-accounts create spinnaker-account \ --display-name spinnaker-account
-
Set env variable
export SA_EMAIL=$(gcloud iam service-accounts list \ --filter="displayName:spinnaker-account" \ --format='value(email)') export PROJECT=$(gcloud info --format='value(config.project)')
-
Bind storage.admin ke service account yang dibuat
gcloud projects add-iam-policy-binding $PROJECT \ --role roles/storage.admin \ --member serviceAccount:$SA_EMAIL
-
Download spinnaker key
gcloud iam service-accounts keys create spinnaker-sa.json \ --iam-account $SA_EMAIL
-
Buat pub.sub
gcloud iam service-accounts keys create spinnaker-sa.json \ --iam-account $SA_EMAIL
-
Buat subscription
gcloud pubsub subscriptions create gcr-triggers \ --topic projects/${PROJECT}/topics/gcr
-
Kasih spinnaker account permission untuk read
export SA_EMAIL=$(gcloud iam service-accounts list \ --filter="displayName:spinnaker-account" \ --format='value(email)') gcloud beta pubsub subscriptions add-iam-policy-binding gcr-triggers \ --role roles/pubsub.subscriber --member serviceAccount:$SA_EMAIL
-
Grant helm ke cluster-admin
kubectl create clusterrolebinding user-admin-binding \ --clusterrole=cluster-admin --user=$(gcloud config get-value account)
-
Kasih juga ke spinnaker
kubectl create clusterrolebinding --clusterrole=cluster-admin \ --serviceaccount=default:default spinnaker-admin
-
Add stable chart ke Helm
helm repo add stable https://charts.helm.sh/stable helm repo update
-
Buat bucket untuk spinnaker simpan conf nyua
export PROJECT=$(gcloud info \ --format='value(config.project)') export BUCKET=$PROJECT-spinnaker-config gsutil mb -c regional -l us-east1 gs://$BUCKET
-
Buat spinnaker config
export SA_JSON=$(cat spinnaker-sa.json) export PROJECT=$(gcloud info --format='value(config.project)') export BUCKET=$PROJECT-spinnaker-config cat > spinnaker-config.yaml <<EOF gcs: enabled: true bucket: $BUCKET project: $PROJECT jsonKey: '$SA_JSON' dockerRegistries: - name: gcr address: https://gcr.io username: _json_key password: '$SA_JSON' email: 1234@5678.com # Disable minio as the default storage backend minio: enabled: false # Configure Spinnaker to enable GCP services halyard: spinnakerVersion: 1.19.4 image: repository: us-docker.pkg.dev/spinnaker-community/docker/halyard tag: 1.32.0 pullSecrets: [] additionalScripts: create: true data: enable_gcs_artifacts.sh: |- \$HAL_COMMAND config artifact gcs account add gcs-$PROJECT --json-path /opt/gcs/key.json \$HAL_COMMAND config artifact gcs enable enable_pubsub_triggers.sh: |- \$HAL_COMMAND config pubsub google enable \$HAL_COMMAND config pubsub google subscription add gcr-triggers \ --subscription-name gcr-triggers \ --json-path /opt/gcs/key.json \ --project $PROJECT \ --message-format GCR EOF
-
Deploy spinnaker
helm install -n default cd stable/spinnaker -f spinnaker-config.yaml \ --version 2.0.0-rc9 --timeout 10m0s --wait
-
Setup port forwarding
export DECK_POD=$(kubectl get pods --namespace default -l "cluster=spin-deck" \ -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward --namespace default $DECK_POD 8080:9000 >> /dev/null &
-
Download sample app
gsutil -m cp -r gs://spls/gsp114/sample-app.tar .
-
Unpack app
mkdir sample-app tar xvf sample-app.tar -C ./sample-app cd sample-app
-
Set username dan email git
git config --global user.email "$(gcloud config get-value core/account)" git config --global user.name "[USERNAME]"
-
Buat repo
gcloud source repos create sample-app
-
Tambah remote
export PROJECT=$(gcloud info --format='value(config.project)') git remote add origin https://source.developers.google.com/p/$PROJECT/r/sample-app
-
Push
git push origin master
-
Buat bucket
export PROJECT=$(gcloud info --format='value(config.project)')
gsutil mb -l us-east1 gs://$PROJECT-kubernetes-manifests
-
Enable versioning
gsutil versioning set on gs://$PROJECT-kubernetes-manifests
-
Set project id
sed -i s/PROJECT/$PROJECT/g k8s/deployments/*
-
Commit
git commit -a -m "Set project ID"
-
But git tag
git tag v1.0.0
-
Push tag
git push --tags
-
Downlod spin
curl -LO https://storage.googleapis.com/spinnaker-artifacts/spin/1.14.0/linux/amd64/spin
-
Mke spin executable
chmod +x spin
-
But pipeline
./spin application save --application-name sample \ --owner-email "$(gcloud config get-value core/account)" \ --cloud-providers kubernetes \ --gate-endpoint http://localhost:8080/gate
-
Uplod pipeline
export PROJECT=$(gcloud info --format='value(config.project)') sed s/PROJECT/$PROJECT/g spinnaker/pipeline-deploy.json > pipeline.json ./spin pipeline save --gate-endpoint http://localhost:8080/gate -f pipeline.json
-
Ganti warn web
sed -i 's/orange/blue/g' cmd/gke-info/common-service.go
-
Commit n push
git commit -a -m "Change color to blue" git tag v1.0.1 git push --tags
-
Rollout
git revert v1.0.1 git tag v1.0.2 git push --tags