K8S CI/CD Skaffold
K8S CI/CD Skaffold
安装 skaffold
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
chmod +x skaffold
sudo mv skaffold /usr/local/bin
运行 skaffold(这里假定你已经有kubectl访问k8s的权限)
通过官方的入门实例,初步了解skaffold的运行机制
git clone https://github.com/GoogleContainerTools/skaffold
cd /root/skaffold/skaffold/examples/getting-started
由于网络访问的问题
修复一下 Dockerfile和skaffold.yaml为你自己docker可访问到的镜像仓库
我这里换成lorahz/skaffold-example
[root@master-1 getting-started]# skaffold dev
Listing files to watch...
- lorahz/skaffold-example
List generated in 2.149171ms
Generating tags...
- lorahz/skaffold-example -> lorahz/skaffold-example:v0.40.0-32-g46c941b-dirty
Tags generated in 33.81834ms
Checking cache...
- lorahz/skaffold-example: Not found. Building
Cache check complete in 550.118µs
Starting build...
Building [lorahz/skaffold-example]...
Sending build context to Docker daemon 3.072kB
Step 1/6 : FROM golang:1.12.9-alpine3.10 as builder
---> e0d646523991
Step 2/6 : COPY main.go .
---> Using cache
---> 0ec728e6825b
Step 3/6 : RUN go build -o /app main.go
---> Using cache
---> 7d74c75794cf
Step 4/6 : FROM alpine:3.10
---> 961769676411
Step 5/6 : CMD ["./app"]
---> Using cache
---> 644542e44070
Step 6/6 : COPY --from=builder /app .
---> Using cache
---> 5eeebe643aa8
Successfully built 5eeebe643aa8
Successfully tagged lorahz/skaffold-example:v0.40.0-32-g46c941b-dirty
The push refers to repository [docker.io/lorahz/skaffold-example]
eb84481ea05f: Preparing
03901b4a2ea8: Preparing
03901b4a2ea8: Mounted from library/alpine
eb84481ea05f: Pushed
v0.40.0-32-g46c941b-dirty: digest: sha256:4caabe3ccc2381896d87e01826d846345ead57b5c30143fde4c1f9013f1feee7 size: 739
Build complete in 48.267244019s
Starting test...
Test complete in 4.619µs
Tags used in deployment:
- lorahz/skaffold-example -> lorahz/skaffold-example:v0.40.0-32-g46c941b-dirty@sha256:4caabe3ccc2381896d87e01826d846345ead57b5c30143fde4c1f9013f1feee7
Starting deploy...
- pod/getting-started created
Deploy complete in 597.926228ms
Watching for changes...
总体感觉还是挺好的
参考: