-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finally commit a demo example that works :D
This example will build two images and then deploy them. It uses the microservice example in Skaffold (just an arbitrary choice of a simple deployment situation with 2 apps). This is the (updated version of) the demo that @dlorenc gave at Jenkins World. It's kind of weird that this adds yet another example; I suggest that as part of #108 we remove the other examples since we've never actually run them successfully: they were added at the beginning of the project as examples of where we wanted to go. Had to update step names b/c using camelcase in container names is not allowed (opened #273 to handle this). Fixes #89
- Loading branch information
1 parent
7fc6a3f
commit 54051bf
Showing
9 changed files
with
224 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: default-cluster-admin | ||
subjects: | ||
- kind: ServiceAccount | ||
name: default | ||
namespace: default | ||
roleRef: | ||
kind: ClusterRole | ||
name: cluster-admin | ||
apiGroup: rbac.authorization.k8s.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: pipeline.knative.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: demo-deploy-kubectl | ||
namespace: default | ||
spec: | ||
inputs: | ||
resources: | ||
- name: workspace | ||
type: git | ||
- name: image | ||
type: image | ||
params: | ||
- name: path | ||
description: Path to the manifest to apply | ||
- name: yqArg | ||
description: Okay this is a hack, but I didn't feel right hard-codeing `-d1` down below | ||
- name: yamlPathToImage | ||
description: The path to the image to replace in the yaml manifest (arg to yq) | ||
clusters: | ||
- name: targetCluster | ||
description: Not yet used, kubectl command below should use this cluster | ||
steps: | ||
- name: replace-image | ||
image: mikefarah/yq | ||
command: ['yq'] | ||
args: | ||
- "w" | ||
- "-i" | ||
- "${inputs.params.yqArg}" | ||
- "${inputs.params.path}" | ||
- "${inputs.params.yamlPathToImage}" | ||
- "${inputs.resources.image.url}" | ||
- name: run-kubectl | ||
image: lachlanevenson/k8s-kubectl | ||
command: ['kubectl'] | ||
args: | ||
- 'apply' | ||
- '-f' | ||
- '${inputs.params.path}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
apiVersion: pipeline.knative.dev/v1alpha1 | ||
kind: Pipeline | ||
metadata: | ||
name: demo-pipeline | ||
namespace: default | ||
spec: | ||
tasks: | ||
- name: build-skaffold-web | ||
taskRef: | ||
name: build-push | ||
params: | ||
- name: pathToDockerFile | ||
value: Dockerfile | ||
- name: pathToContext | ||
value: /workspace/examples/microservices/leeroy-web | ||
- name: build-skaffold-app | ||
taskRef: | ||
name: build-push | ||
params: | ||
- name: pathToDockerFile | ||
value: Dockerfile | ||
- name: pathToContext | ||
value: /workspace/examples/microservices/leeroy-app | ||
- name: deploy-app | ||
taskRef: | ||
name: demo-deploy-kubectl | ||
resources: | ||
- name: image | ||
providedBy: | ||
- build-skaffold-app | ||
params: | ||
- name: path | ||
value: /workspace/examples/microservices/leeroy-app/kubernetes/deployment.yaml | ||
- name: yqArg | ||
value: "-d1" | ||
- name: yamlPathToImage | ||
value: "spec.template.spec.containers[0].image" | ||
- name: deploy-web | ||
taskRef: | ||
name: demo-deploy-kubectl | ||
inputSourceBindings: | ||
- name: image | ||
providedBy: | ||
- build-skaffold-web | ||
params: | ||
- name: path | ||
value: /workspace/examples/microservices/leeroy-web/kubernetes/deployment.yaml | ||
- name: yqArg | ||
value: "-d1" | ||
- name: yamlPathToImage | ||
value: "spec.template.spec.containers[0].image" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
apiVersion: pipeline.knative.dev/v1alpha1 | ||
kind: PipelineResource | ||
metadata: | ||
name: skaffold-git | ||
namespace: default | ||
spec: | ||
type: git | ||
params: | ||
- name: revision | ||
value: master | ||
- name: url | ||
value: https://github.com/GoogleContainerTools/skaffold | ||
--- | ||
apiVersion: pipeline.knative.dev/v1alpha1 | ||
kind: PipelineResource | ||
metadata: | ||
name: skaffold-image-leeroy-web | ||
namespace: default | ||
spec: | ||
type: image | ||
params: | ||
- name: url | ||
value: gcr.io/christiewilson-catfactory/leeroy-web | ||
--- | ||
apiVersion: pipeline.knative.dev/v1alpha1 | ||
kind: PipelineResource | ||
metadata: | ||
name: skaffold-image-leeroy-app | ||
namespace: default | ||
spec: | ||
type: image | ||
params: | ||
- name: url | ||
value: gcr.io/christiewilson-catfactory/leeroy-app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
apiVersion: pipeline.knative.dev/v1alpha1 | ||
kind: PipelineRun | ||
metadata: | ||
name: demo-pipeline-run-1 | ||
namespace: default | ||
spec: | ||
pipelineRef: | ||
name: demo-pipeline | ||
pipelineParamsRef: | ||
name: pipelineparams-sample | ||
triggerRef: | ||
type: manual | ||
resources: | ||
- name: build-skaffold-web | ||
inputs: | ||
- name: workspace | ||
resourceRef: | ||
name: skaffold-git | ||
outputs: | ||
- name: builtImage | ||
resourceRef: | ||
name: skaffold-image-leeroy-web | ||
- name: build-skaffold-app | ||
inputs: | ||
- name: workspace | ||
resourceRef: | ||
name: skaffold-git | ||
outputs: | ||
- name: builtImage | ||
resourceRef: | ||
name: skaffold-image-leeroy-app | ||
- name: deploy-app | ||
inputs: | ||
- name: workspace | ||
resourceRef: | ||
name: skaffold-git | ||
- name: image | ||
resourceRef: | ||
name: skaffold-image-leeroy-app | ||
- name: deploy-web | ||
inputs: | ||
- name: workspace | ||
resourceRef: | ||
name: skaffold-git | ||
- name: image | ||
resourceRef: | ||
name: skaffold-image-leeroy-web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters