GoogleCloudPlatform / skaffold
- воскресенье, 18 марта 2018 г. в 17:53:19
Go
Easy and Repeatable Kubernetes Development
Skaffold is a command line tool that facilitates continuous development for Kubernetes applications. You can iterate on your application source code locally then deploy to local or remote Kubernetes clusters. Skaffold handles the workflow for building, pushing and deploying your application. It can also be used in an automated context such as a CI/CD pipeline to leverage the same workflow and tooling when moving applications to production.
Skaffold has a pluggable architecture that allows you to choose the tools in the developer workflow that work best for you.
Updates your deployed application continually:
Run runs a Skaffold pipeline once, exits on any errors in the pipeline.
Use for:
For getting started with Google Kubernetes Engine and Container Builder go here. Otherwise continue below to get started with a local Kubernetes cluster.
You will need the following components to get started with Skaffold:
skaffold
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && chmod +x skaffold && sudo mv skaffold /usr/local/bin
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-darwin-amd64 && chmod +x skaffold && sudo mv skaffold /usr/local/bin
Kubernetes Cluster
docker
Docker image registry
gcloud
's Docker credential helper: Run gcloud beta auth configure-docker
docker-credential-gcr
gcloud docker -a
before each development session.git clone https://github.com/GoogleCloudPlatform/skaffold
getting-started
example.cd examples/getting-started
Change the imageName
and IMAGE_NAME
parameters of skaffold.yaml
. This should be a fully qualified image name that your docker client is configured to push to.
Run skaffold dev
.
$ skaffold dev
Starting build...
Found minikube or Docker for Desktop context, using local docker daemon.
Sending build context to Docker daemon 7.68kB
Step 1/5 : FROM golang:1.9.4-alpine3.7
---> fb6e10bf973b
Step 2/5 : WORKDIR /go/src/github.com/GoogleCloudPlatform/skaffold/examples/getting-started
---> Using cache
---> 259762612c45
Step 3/5 : CMD ./app
---> Using cache
---> e2cb5a3e8812
Step 4/5 : COPY main.go .
---> Using cache
---> 149d709c4fd9
Step 5/5 : RUN go build -o app main.go
---> Using cache
---> a688409b7e69
Successfully built a688409b7e69
Successfully tagged 97e2a15e650c6470fb30e1cdcc808b59:latest
Successfully tagged changeme:a688409b7e696dec944a36a1fe4063fa7b6726891be75809d4ec8f180e2ccc96
Build complete.
Starting deploy...
Deploying examples/getting-started/k8s-pod.yaml...
Deploy complete.
[getting-started getting-started] Hello world!
skaffold.yaml
kubectl apply -f
[getting-started getting-started] Hello world!
[getting-started getting-started] Hello world!
[getting-started getting-started] Hello world!
Now, update main.go
diff --git a/examples/getting-started/main.go b/examples/getting-started/main.go
index 64b7bdfc..f95e053d 100644
--- a/examples/getting-started/main.go
+++ b/examples/getting-started/main.go
@@ -7,7 +7,7 @@ import (
func main() {
for {
- fmt.Println("Hello world!")
+ fmt.Println("Hello jerry!")
time.Sleep(time.Second * 1)
}
}
Once you save the file, you should see the pipeline kick off again to redeploy your application:
[getting-started getting-started] Hello jerry!
[getting-started getting-started] Hello jerry!
There may be some cases where you don't want to run build and deploy continuously. To run once, use:
$ skaffold run -f skaffold.yaml