Skip to content

Instantly share code, notes, and snippets.

@loudej
Created December 10, 2021 02:48
Show Gist options
  • Save loudej/a21df2a3e3b7ba3b5a01ef94aba9b14a to your computer and use it in GitHub Desktop.
Save loudej/a21df2a3e3b7ba3b5a01ef94aba9b14a to your computer and use it in GitHub Desktop.
kpt oci example usage
function section() {
echo "$(tput setaf 6)$@$(tput sgr0)" 1>&2
}
function blueprint_clone() {
rm -r gke
section "New clone of gke at v0.3.0"
kpt pkg get https://github.com/GoogleCloudPlatform/blueprints.git/catalog/gke@v0.3.0
section "Push my-blueprints/gke at v1"
kpt pkg push gke --origin oci://us-docker.pkg.dev/rickon-fishfood/my-blueprints/gke:v1
}
function blueprint_update() {
rm -r gke
section "Pull my-blueprints/gke at v1"
kpt pkg pull oci://us-docker.pkg.dev/rickon-fishfood/my-blueprints/gke:v1
section "Jump to the upstream's main version"
kpt pkg update gke@main
section "Push my-blueprints/gke at v2"
kpt pkg push gke --increment
}
function instance_clone() {
rm -r sales-cluster
section "New instance named sales-cluster based on my copy of gke"
kpt pkg get oci://us-docker.pkg.dev/rickon-fishfood/my-blueprints/gke:v2 sales-cluster
section "Assign origin and push draft copy"
kpt pkg push sales-cluster@draft --origin oci://us-docker.pkg.dev/rickon-fishfood/installed/sales-cluster
section "Push updates to sales-cluster still as draft"
kpt pkg push sales-cluster
section "Push updates to sales-cluser at v1 explicitly"
kpt pkg push sales-cluster@v1
section "Push updates to sales-cluser at v2"
kpt pkg push sales-cluster --increment
}
function instance_update() {
rm -r sales-cluster
section "Pulling a copy of sales-cluster at v2"
kpt pkg pull oci://us-docker.pkg.dev/rickon-fishfood/installed/sales-cluster:v2
section "Switching upstream to v2 (note: upstream and origin version are unrelated!)"
kpt pkg update sales-cluster@v2
section "Pushing sales-cluster at v3"
kpt pkg push sales-cluster --increment
}
function all() {
blueprint_clone
blueprint_update
instance_clone
instance_update
}
"$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment