Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor KanikoBuild into KanikoArtifact and Cluster #1797

Merged
merged 10 commits into from
Mar 15, 2019
10 changes: 6 additions & 4 deletions docs/content/en/samples/builders/kaniko.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
build:
artifacts:
- image: gcr.io/k8s-skaffold/example
kaniko:
buildContext:
gcsBucket: YOUR-BUCKET
- image: gcr.io/k8s-skaffold/example
kaniko:
buildContext:
gcsBucket: YOUR-BUCKET
cluster:
pullSecretName: YOUR-PULL-SECRET-NAME
185 changes: 137 additions & 48 deletions docs/content/en/schemas/v1beta7.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,54 @@
"jibGradle"
],
"additionalProperties": false
},
{
"properties": {
"context": {
"type": "string",
"description": "directory containing the artifact's sources.",
"x-intellij-html-description": "directory containing the artifact's sources.",
"default": "."
},
"image": {
"type": "string",
"description": "name of the image to be built.",
"x-intellij-html-description": "name of the image to be built.",
"examples": [
"gcr.io/k8s-skaffold/example"
]
},
"kaniko": {
"$ref": "#/definitions/KanikoArtifact",
"description": "*alpha* builds images using [kaniko](https://github.com/GoogleContainerTools/kaniko).",
"x-intellij-html-description": "<em>alpha</em> builds images using <a href=\"https://github.com/GoogleContainerTools/kaniko\">kaniko</a>."
},
"plugin": {
"$ref": "#/definitions/BuilderPlugin",
"description": "plugin used to build this artifact.",
"x-intellij-html-description": "plugin used to build this artifact."
},
"sync": {
"additionalProperties": {
"type": "string"
},
"type": "object",
"description": "*alpha* local files synced to pods instead of triggering an image build when modified. This is a mapping of local files to sync to remote folders.",
"x-intellij-html-description": "<em>alpha</em> local files synced to pods instead of triggering an image build when modified. This is a mapping of local files to sync to remote folders.",
"default": "{}",
"examples": [
"{\"*.py\": \".\", \"css/**/*.css\": \"app/css\"}"
]
}
},
"preferredOrder": [
"image",
"context",
"sync",
"plugin",
"kaniko"
],
"additionalProperties": false
}
],
"description": "items that need to be built, along with the context in which they should be built.",
Expand All @@ -307,13 +355,19 @@
"$ref": "#/definitions/JibMavenArtifact",
"description": "*alpha* builds images using the [Jib plugin for Maven](https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin).",
"x-intellij-html-description": "<em>alpha</em> builds images using the <a href=\"https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin\">Jib plugin for Maven</a>."
},
"kaniko": {
"$ref": "#/definitions/KanikoArtifact",
"description": "*alpha* builds images using [kaniko](https://github.com/GoogleContainerTools/kaniko).",
"x-intellij-html-description": "<em>alpha</em> builds images using <a href=\"https://github.com/GoogleContainerTools/kaniko\">kaniko</a>."
}
},
"preferredOrder": [
"docker",
"bazel",
"jibMaven",
"jibGradle"
"jibGradle",
"kaniko"
],
"additionalProperties": false,
"description": "describes how to build an artifact.",
Expand Down Expand Up @@ -461,16 +515,16 @@
"description": "the images you're going to be building.",
"x-intellij-html-description": "the images you're going to be building."
},
"cluster": {
"$ref": "#/definitions/ClusterDetails",
"description": "*beta* describes how to do an on-cluster build.",
"x-intellij-html-description": "<em>beta</em> describes how to do an on-cluster build."
},
"executionEnvironment": {
"$ref": "#/definitions/ExecutionEnvironment",
"description": "environment in which the build should run. Possible values: googleCloudBuild.",
"x-intellij-html-description": "environment in which the build should run. Possible values: googleCloudBuild."
},
"kaniko": {
"$ref": "#/definitions/KanikoBuild",
"description": "*beta* describes how to do an on-cluster build using [Kaniko](https://github.com/GoogleContainerTools/kaniko).",
"x-intellij-html-description": "<em>beta</em> describes how to do an on-cluster build using <a href=\"https://github.com/GoogleContainerTools/kaniko\">Kaniko</a>."
},
"tagPolicy": {
"$ref": "#/definitions/TagPolicy",
"description": "*beta* determines how images are tagged. A few strategies are provided here, although you most likely won't need to care! If not specified, it defaults to `gitCommit: {}`.",
Expand All @@ -481,7 +535,7 @@
"artifacts",
"tagPolicy",
"executionEnvironment",
"kaniko"
"cluster"
],
"additionalProperties": false
}
Expand All @@ -491,16 +545,16 @@
},
"BuildType": {
"properties": {
"cluster": {
"$ref": "#/definitions/ClusterDetails",
"description": "*beta* describes how to do an on-cluster build.",
"x-intellij-html-description": "<em>beta</em> describes how to do an on-cluster build."
},
"googleCloudBuild": {
"$ref": "#/definitions/GoogleCloudBuild",
"description": "*beta* describes how to do a remote build on [Google Cloud Build](https://cloud.google.com/cloud-build/).",
"x-intellij-html-description": "<em>beta</em> describes how to do a remote build on <a href=\"https://cloud.google.com/cloud-build/\">Google Cloud Build</a>."
},
"kaniko": {
"$ref": "#/definitions/KanikoBuild",
"description": "*beta* describes how to do an on-cluster build using [Kaniko](https://github.com/GoogleContainerTools/kaniko).",
"x-intellij-html-description": "<em>beta</em> describes how to do an on-cluster build using <a href=\"https://github.com/GoogleContainerTools/kaniko\">Kaniko</a>."
},
"local": {
"$ref": "#/definitions/LocalBuild",
"description": "*beta* describes how to do a build on the local docker daemon and optionally push to a repository.",
Expand All @@ -510,7 +564,7 @@
"preferredOrder": [
"local",
"googleCloudBuild",
"kaniko"
"cluster"
],
"additionalProperties": false,
"description": "contains the specific implementation and parameters needed for the build step. Only one field should be populated.",
Expand Down Expand Up @@ -539,6 +593,46 @@
"description": "contains all fields necessary for specifying a build plugin.",
"x-intellij-html-description": "contains all fields necessary for specifying a build plugin."
},
"ClusterDetails": {
"properties": {
"dockerConfig": {
"$ref": "#/definitions/DockerConfig",
"description": "describes how to mount the local Docker configuration into a pod.",
"x-intellij-html-description": "describes how to mount the local Docker configuration into a pod."
},
"namespace": {
"type": "string",
"description": "Kubernetes namespace. Defaults to current namespace in Kubernetes configuration.",
"x-intellij-html-description": "Kubernetes namespace. Defaults to current namespace in Kubernetes configuration."
},
"pullSecret": {
"type": "string",
"description": "path to the secret key file.",
"x-intellij-html-description": "path to the secret key file."
},
"pullSecretName": {
"type": "string",
"description": "name of the Kubernetes secret for pulling the files from the build context and pushing the final image.",
"x-intellij-html-description": "name of the Kubernetes secret for pulling the files from the build context and pushing the final image.",
"default": "kaniko-secret"
},
"timeout": {
"type": "string",
"description": "amount of time (in seconds) that this build is allowed to run. Defaults to 20 minutes (`20m`).",
"x-intellij-html-description": "amount of time (in seconds) that this build is allowed to run. Defaults to 20 minutes (<code>20m</code>)."
}
},
"preferredOrder": [
"pullSecret",
"pullSecretName",
"namespace",
"timeout",
"dockerConfig"
],
"additionalProperties": false,
"description": "*beta* describes how to do an on-cluster build.",
"x-intellij-html-description": "<em>beta</em> describes how to do an on-cluster build."
},
"DateTimeTagger": {
"properties": {
"format": {
Expand Down Expand Up @@ -1201,22 +1295,35 @@
"description": "*alpha* builds images using the [Jib plugin for Maven](https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin).",
"x-intellij-html-description": "<em>alpha</em> builds images using the <a href=\"https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin\">Jib plugin for Maven</a>."
},
"KanikoBuild": {
"KanikoArtifact": {
"properties": {
"buildArgs": {
"additionalProperties": {
"type": "string"
},
"type": "object",
"description": "arguments passed to the docker build.",
"x-intellij-html-description": "arguments passed to the docker build.",
"default": "{}",
"examples": [
"{\"key1\": \"value1\", \"key2\": \"value2\"}"
]
},
"buildContext": {
"$ref": "#/definitions/KanikoBuildContext",
"description": "defines where Kaniko gets the sources from.",
"x-intellij-html-description": "defines where Kaniko gets the sources from."
"description": "where the build context for this artifact resides.",
"x-intellij-html-description": "where the build context for this artifact resides."
},
"cache": {
"$ref": "#/definitions/KanikoCache",
"description": "configures Kaniko caching. If a cache is specified, Kaniko will use a remote cache which will speed up builds.",
"x-intellij-html-description": "configures Kaniko caching. If a cache is specified, Kaniko will use a remote cache which will speed up builds."
},
"dockerConfig": {
"$ref": "#/definitions/DockerConfig",
"description": "describes how to mount the local Docker configuration into the Kaniko pod.",
"x-intellij-html-description": "describes how to mount the local Docker configuration into the Kaniko pod."
"dockerfile": {
"type": "string",
"description": "locates the Dockerfile relative to workspace.",
"x-intellij-html-description": "locates the Dockerfile relative to workspace.",
"default": "Dockerfile"
},
"flags": {
"items": {
Expand All @@ -1232,42 +1339,24 @@
"description": "Docker image used by the Kaniko pod. Defaults to the latest released version of `gcr.io/kaniko-project/executor`.",
"x-intellij-html-description": "Docker image used by the Kaniko pod. Defaults to the latest released version of <code>gcr.io/kaniko-project/executor</code>."
},
"namespace": {
"type": "string",
"description": "Kubernetes namespace. Defaults to current namespace in Kubernetes configuration.",
"x-intellij-html-description": "Kubernetes namespace. Defaults to current namespace in Kubernetes configuration."
},
"pullSecret": {
"type": "string",
"description": "path to the secret key file. See [Kaniko Documentation](https://github.com/GoogleContainerTools/kaniko#running-kaniko-in-a-kubernetes-cluster).",
"x-intellij-html-description": "path to the secret key file. See <a href=\"https://github.com/GoogleContainerTools/kaniko#running-kaniko-in-a-kubernetes-cluster\">Kaniko Documentation</a>."
},
"pullSecretName": {
"type": "string",
"description": "name of the Kubernetes secret for pulling the files from the build context and pushing the final image.",
"x-intellij-html-description": "name of the Kubernetes secret for pulling the files from the build context and pushing the final image.",
"default": "kaniko-secret"
},
"timeout": {
"target": {
"type": "string",
"description": "amount of time (in seconds) that this build is allowed to run. Defaults to 20 minutes (`20m`).",
"x-intellij-html-description": "amount of time (in seconds) that this build is allowed to run. Defaults to 20 minutes (<code>20m</code>)."
"description": "Dockerfile target name to build.",
"x-intellij-html-description": "Dockerfile target name to build."
}
},
"preferredOrder": [
"buildContext",
"cache",
"flags",
"pullSecret",
"pullSecretName",
"namespace",
"timeout",
"dockerfile",
"target",
"buildArgs",
"buildContext",
"image",
"dockerConfig"
"cache"
],
"additionalProperties": false,
"description": "*beta* describes how to do an on-cluster build using [Kaniko](https://github.com/GoogleContainerTools/kaniko).",
"x-intellij-html-description": "<em>beta</em> describes how to do an on-cluster build using <a href=\"https://github.com/GoogleContainerTools/kaniko\">Kaniko</a>."
"description": "*alpha* describes an artifact built from a Dockerfile, with kaniko.",
"x-intellij-html-description": "<em>alpha</em> describes an artifact built from a Dockerfile, with kaniko."
},
"KanikoBuildContext": {
"properties": {
Expand Down
13 changes: 6 additions & 7 deletions integration/examples/kaniko-local/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ apiVersion: skaffold/v1beta7
kind: Config
build:
artifacts:
- image: gcr.io/k8s-skaffold/skaffold-example
kaniko:
buildContext:
localDir: {}
- image: gcr.io/k8s-skaffold/skaffold-example
kaniko:
buildContext:
localDir: {}
cache: {}
cluster:
pullSecretName: e2esecret
namespace: default
cache: {}
flags:
- --single-snapshot
deploy:
kubectl:
manifests:
Expand Down
11 changes: 6 additions & 5 deletions integration/examples/kaniko/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ apiVersion: skaffold/v1beta7
kind: Config
build:
artifacts:
- image: gcr.io/k8s-skaffold/skaffold-example
kaniko:
buildContext:
gcsBucket: skaffold-kaniko
- image: gcr.io/k8s-skaffold/skaffold-example
kaniko:
buildContext:
gcsBucket: skaffold-kaniko
cache: {}
cluster:
pullSecretName: e2esecret
namespace: default
cache: {}
deploy:
kubectl:
manifests:
Expand Down
5 changes: 5 additions & 0 deletions integration/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ func TestRun(t *testing.T) {
dir: "testdata/kaniko-sub-folder",
pods: []string{"getting-started-kaniko"},
remoteOnly: true,
}, {
description: "kaniko microservices",
dir: "testdata/kaniko-microservices",
deployments: []string{"leeroy-app", "leeroy-web"},
remoteOnly: true,
}, {
description: "helm",
dir: "examples/helm-deployment",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.10.1-alpine3.7 as builder
COPY app.go .
RUN go build -o /app .

FROM alpine:3.7 as target_stage
CMD ["./app"]
COPY --from=builder /app .

FROM busybox
17 changes: 17 additions & 0 deletions integration/testdata/kaniko-microservices/leeroy-app/app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import (
"fmt"
"log"
"net/http"
)

func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "leeroooooy app!!\n")
}

func main() {
log.Print("leeroy app server ready")
http.HandleFunc("/", handler)
http.ListenAndServe(":50051", nil)
}
Loading