Skip to content

Instantly share code, notes, and snippets.

@louisvernon
Last active February 27, 2021 00:36
Show Gist options
  • Save louisvernon/58e2c0cefb493a1e39326fb642d9af88 to your computer and use it in GitHub Desktop.
Save louisvernon/58e2c0cefb493a1e39326fb642d9af88 to your computer and use it in GitHub Desktop.
Spinnaker Kubernetes v2 Pipeline
{
"expectedArtifacts": [
{
"id": "deployment-manifest",
"defaultArtifact": {
"kind": "default.github",
"name": "services/myapp/k8s/deployment.yaml",
"reference": "https://api.github.com/repos/myorg/monorepo/contents/services/myapp/k8s/deployment.yaml",
"type": "github/file",
"version": "master"
},
"matchArtifact": {
"kind": "github",
"name": "services/myapp/k8s/deployment.yaml",
"type": "github/file"
},
"useDefaultArtifact": true,
"usePriorExecution": false
},
{
"id": "configmap-staging",
"defaultArtifact": {
"kind": "default.github",
"name": "services/myapp/k8s/configmap.yaml",
"reference": "https://api.github.com/repos/myorg/monorepo/contents/services/myapp/k8s/configmap.yaml",
"type": "github/file",
"version": "master"
},
"matchArtifact": {
"kind": "github",
"name": "services/myapp/k8s/configmap.yaml",
"type": "github/file"
},
"useDefaultArtifact": true,
"usePriorExecution": false
},
{
"id": "configmap-production",
"defaultArtifact": {
"kind": "default.github",
"name": "services/myapp/k8s/configmap.yaml",
"reference": "https://api.github.com/repos/myorg/monorepo/contents/services/myapp/k8s/configmap.yaml",
"type": "github/file",
"version": "master"
},
"matchArtifact": {
"kind": "github",
"name": "services/myapp/k8s/configmap.yaml",
"type": "github/file"
},
"useDefaultArtifact": true,
"usePriorExecution": false
},
{
"defaultArtifact": {
"kind": "default.docker",
"name": "us.gcr.io/myorg/myapp/prod",
"reference": "us.gcr.io/myorg/myapp/prod:latest",
"type": "docker/image"
},
"id": "image",
"matchArtifact": {
"kind": "docker",
"name": "us.gcr.io/myorg/myapp/prod",
"type": "docker/image"
},
"useDefaultArtifact": true,
"usePriorArtifact": false
}
],
"keepWaitingPipelines": false,
"lastModifiedBy": "anonymous",
"limitConcurrent": true,
"parameterConfig": [
{
"default": "staging",
"name": "staging-namespace"
},
{
"default": "prod",
"name": "production-namespace"
},
{
"default": "automatic",
"description": "Use the container image currently in production, or specify an override.",
"name": "image-tag"
}
],
"stages": [
{
"name": "ConfigMap in Staging",
"refId": "configmap-staging",
"account": "mycluster",
"cloudProvider": "kubernetes",
"manifestArtifactAccount": "github-artifact-account",
"manifestArtifactId": "configmap-staging",
"moniker": {
"app": "myapp"
},
"requisiteStageRefIds": [
"populateartifacts"
],
"source": "artifact",
"target-namespace": "${parameters['staging-namespace']}",
"type": "deployManifest"
},
{
"name": "Deployment in Staging",
"refId": "deployment-staging",
"account": "mycluster",
"cloudProvider": "kubernetes",
"manifestArtifactAccount": "github-artifact-account",
"manifestArtifactId": "deployment-manifest",
"moniker": {
"app": "myapp"
},
"requisiteStageRefIds": [
"configmap-staging"
],
"source": "artifact",
"target-namespace": "${parameters['staging-namespace']}",
"type": "deployManifest"
},
{
"name": "Manual Judgment",
"refId": "manualjudgement",
"failPipeline": true,
"instructions": "Promote service to production?",
"judgmentInputs": [],
"notifications": [],
"overrideTimeout": true,
"requisiteStageRefIds": [
"deployment-staging"
],
"stageTimeoutMs": 3600000,
"type": "manualJudgment"
},
{
"name": "ConfigMap in Production",
"refId": "configmap-production",
"account": "mycluster",
"cloudProvider": "kubernetes",
"manifestArtifactAccount": "github-artifact-account",
"manifestArtifactId": "configmap-production",
"moniker": {
"app": "myapp"
},
"requisiteStageRefIds": [
"manualjudgement"
],
"source": "artifact",
"target-namespace": "${parameters['production-namespace']}",
"type": "deployManifest"
},
{
"name": "Deployment in Production",
"refId": "deployment-production",
"account": "mycluster",
"cloudProvider": "kubernetes",
"manifestArtifactAccount": "github-artifact-account",
"manifestArtifactId": "deployment-manifest",
"moniker": {
"app": "myapp"
},
"requisiteStageRefIds": [
"configmap-production"
],
"source": "artifact",
"target-namespace": "${parameters['production-namespace']}",
"type": "deployManifest"
},
{
"name": "Get Image from Prod",
"refId": "getimagefromprod",
"account": "mycluster",
"cloudProvider": "kubernetes",
"location": "${parameters['production-namespace']}",
"manifestName": "deployment myapp",
"stageEnabled": {
"expression": "${execution['trigger']['type'] != 'pubsub' && parameters['image-tag'] == 'automatic' }",
"type": "expression"
},
"type": "findArtifactsFromResource"
},
{
"${ trigger['artifacts'].?[type == 'docker/image'][0]['reference'] = trigger['artifacts'].?[type == 'docker/image'][0]['name'] + ':' + parameters['image-tag']}": "true",
"${ trigger['payload']['digest'] = trigger['payload']['tag'] }": "true",
"${ trigger['artifacts'].?[type == 'docker/image'][0]['reference'] = trigger['payload']['tag'] }": "true",
"${ trigger['resolvedExpectedArtifacts'].?[id == 'image'][0]['boundArtifact']['version'] = trigger['payload']['tag'].split(':')[1] }": "true",
"${ trigger['resolvedExpectedArtifacts'].?[id == 'image'][0]['boundArtifact']['reference'] = trigger['payload']['tag'] }": "true",
"name": "Wait",
"refId": "populateartifacts",
"requisiteStageRefIds": [
"getimagefromprod"
],
"type": "wait",
"waitTime": 1
}
],
"triggers": [
{
"application": "myapp",
"branch": "master",
"enabled": true,
"expectedArtifactIds": [
"deployment-manifest",
"configmap-staging",
"configmap-production"
],
"pipeline": "manifest_deployment",
"project": "myorg",
"secret": "${GITHUB_SECRET}",
"slug": "monorepo",
"source": "github",
"status": [
"successful"
],
"type": "git"
},
{
"attributeConstraints": {},
"enabled": true,
"expectedArtifactIds": [
"image"
],
"payloadConstraints": {},
"pubsubSystem": "google",
"subscriptionName": "spingcr",
"type": "pubsub"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment