Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
briandealwis committed Aug 4, 2021
2 parents 6571e37 + cf4aab8 commit b97f8bf
Show file tree
Hide file tree
Showing 256 changed files with 7,580 additions and 781 deletions.
48 changes: 24 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,30 +114,30 @@ jobs:
<<: *registry_mirror
script:
- env IT_PARTITION=3 make integration-in-kind
# - name: "k3d integration partition 0"
# <<: *integration_test
# <<: *upgrade_docker
# <<: *registry_mirror
# script:
# - env IT_PARTITION=0 make integration-in-k3d
# - name: "k3d integration partition 1"
# <<: *integration_test
# <<: *upgrade_docker
# <<: *registry_mirror
# script:
# - env IT_PARTITION=1 make integration-in-k3d
# - name: "k3d integration partition 2"
# <<: *integration_test
# <<: *upgrade_docker
# <<: *registry_mirror
# script:
# - env IT_PARTITION=2 make integration-in-k3d
# - name: "k3d integration partition 3"
# <<: *integration_test
# <<: *upgrade_docker
# <<: *registry_mirror
# script:
# - env IT_PARTITION=3 make integration-in-k3d
- name: "k3d integration partition 0"
<<: *integration_test
<<: *upgrade_docker
<<: *registry_mirror
script:
- env IT_PARTITION=0 make integration-in-k3d
- name: "k3d integration partition 1"
<<: *integration_test
<<: *upgrade_docker
<<: *registry_mirror
script:
- env IT_PARTITION=1 make integration-in-k3d
- name: "k3d integration partition 2"
<<: *integration_test
<<: *upgrade_docker
<<: *registry_mirror
script:
- env IT_PARTITION=2 make integration-in-k3d
- name: "k3d integration partition 3"
<<: *integration_test
<<: *upgrade_docker
<<: *registry_mirror
script:
- env IT_PARTITION=3 make integration-in-k3d
- os: linux
name: "diag/Linux unit"
<<: *registry_mirror
Expand Down
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,53 @@
# v1.29.0 Release - 07/30/2021
Note: This release comes with a new config version, `v2beta20`. To upgrade your skaffold.yaml, use `skaffold fix`. If you choose not to upgrade, skaffold will auto-upgrade as best as it can.

Highlights:
* Introducing Skaffold lifecycle hooks [#6330](https://github.com/GoogleContainerTools/skaffold/pull/6330)
* Rename Skaffold's `master` branch to `main` [#6263](https://github.com/GoogleContainerTools/skaffold/pull/6263)
* Add state to event handler to track `logrus` output events [#6272](https://github.com/GoogleContainerTools/skaffold/pull/6272)
* fix: kubeContext override via flag [#6331](https://github.com/GoogleContainerTools/skaffold/pull/6331)
* Added developer journey tutorial [#6201](https://github.com/GoogleContainerTools/skaffold/pull/6201)

Fixes:
* Fix tail false but still log issue [#6299](https://github.com/GoogleContainerTools/skaffold/pull/6299)
* skip manifest validation for default `kubectl deployer` [#6294](https://github.com/GoogleContainerTools/skaffold/pull/6294)
* Fix switched container/pod names in app log event [#6215](https://github.com/GoogleContainerTools/skaffold/pull/6215)
* fix remote branch lookup [#6269](https://github.com/GoogleContainerTools/skaffold/pull/6269)
* [cherry-pick] Fix Workdir error when --filename flag is used. [#6247](https://github.com/GoogleContainerTools/skaffold/pull/6247)
* Make skaffold reproducible [#6238](https://github.com/GoogleContainerTools/skaffold/pull/6238)

Updates and Refactors:
* Give `logrus.Hook` implementation information about task and subtask [#6313](https://github.com/GoogleContainerTools/skaffold/pull/6313)
* Add `logrus.Logger` return type on `WithEventContext()` [#6309](https://github.com/GoogleContainerTools/skaffold/pull/6309)
* Add `logrus` hook for sending `SkaffoldLogEvent`s [#6250](https://github.com/GoogleContainerTools/skaffold/pull/6250)

* Prefix port forward links with `http://` [#6295](https://github.com/GoogleContainerTools/skaffold/pull/6295)
* Set output event context in cache check, tag generation, status check, port forward [#6234](https://github.com/GoogleContainerTools/skaffold/pull/6234)


Docs, Test, and Release Updates:
* Update deps and restore k3d tests [#6280](https://github.com/GoogleContainerTools/skaffold/pull/6280)
* Remove log tail test for nodejs example [#6275](https://github.com/GoogleContainerTools/skaffold/pull/6275)
* `git fetch` origin/main before `make checks` [#6274](https://github.com/GoogleContainerTools/skaffold/pull/6274)


Huge thanks goes out to all of our contributors for this release:

- Aaron Prindle
- Benjamin P. Jung
- Brian de Alwis
- Chris Willis
- dependabot[bot]
- elnoro
- Gaurav
- jelle van der Waa
- Marlon Gamez
- Nick Kubala
- Tejal Desai
- Yanshu
- Yuwen Ma


# v1.28.0 Release - 07/14/2021
Note: This release comes with a new config version, `v2beta19`. To upgrade your skaffold.yaml, use `skaffold fix`. If you choose not to upgrade, skaffold will auto-upgrade as best as it can.

Expand Down
2 changes: 1 addition & 1 deletion cmd/skaffold/app/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func setUpLogs(stdErr io.Writer, level string, timestamp bool) error {
logrus.SetFormatter(&logrus.TextFormatter{
FullTimestamp: timestamp,
})
logrus.AddHook(event.NewLogHook())
logrus.AddHook(event.NewLogHook(constants.DevLoop, event.SubtaskIDNone))
return nil
}

Expand Down
9 changes: 0 additions & 9 deletions cmd/skaffold/app/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,6 @@ var flagRegistry = []Flag{
FlagAddMethod: "IntVar",
DefinedOn: []string{"dev", "build", "run", "debug", "deploy"},
},
{
Name: "v2",
Usage: "Next skaffold config (v2). Use kpt to render/hydrate and deploy manifests.",
Value: &opts.Experimental,
DefValue: false,
FlagAddMethod: "BoolVar",
DefinedOn: []string{"apply", "debug", "deploy", "dev", "run"},
IsEnum: true,
},
{
Name: "digest-source",
Usage: "Set to 'remote' to skip builds and resolve the digest of images by tag from the remote registry. Set to 'local' to build images locally and use digests from built images. Set to 'tag' to use tags directly from the build. Set to 'none' to use tags directly from the Kubernetes manifests.",
Expand Down
2 changes: 1 addition & 1 deletion deploy/skaffold/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

# This base image has to be updated manually after running `make build_deps`
FROM gcr.io/k8s-skaffold/build_deps:6477c2b624b633dee1d4c66bdd02821d25ce3f86 as build
FROM gcr.io/k8s-skaffold/build_deps:e34c0c143e9fe6c39a4f119547289d7142afcb0d as build
WORKDIR /skaffold

FROM build as builder
Expand Down
10 changes: 5 additions & 5 deletions deploy/skaffold/Dockerfile.deps
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN chmod +x kubectl

# Download helm (see https://github.com/helm/helm/releases/latest)
FROM alpine:3.10 as download-helm
ENV HELM_VERSION v3.6.2
ENV HELM_VERSION v3.6.3
ENV HELM_URL https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz
RUN wget -O helm.tar.gz "${HELM_URL}"
RUN tar -xvf helm.tar.gz --strip-components 1
Expand All @@ -37,14 +37,14 @@ RUN tar -xvf kustomize.tar.gz

# Download kpt
FROM alpine:3.10 as download-kpt
ENV KPT_VERSION 1.0.0-beta.1
ENV KPT_VERSION 1.0.0-beta.2
ENV KPT_URL https://github.com/GoogleContainerTools/kpt/releases/download/v${KPT_VERSION}/kpt_linux_amd64
RUN wget -O kpt "${KPT_URL}"
RUN chmod +x kpt

# Download kompose
FROM alpine:3.10 as download-kompose
ENV KOMPOSE_VERSION v1.22.0
ENV KOMPOSE_VERSION v1.23.0
ENV KOMPOSE_URL https://github.com/kubernetes/kompose/releases/download/${KOMPOSE_VERSION}/kompose-linux-amd64
RUN wget -O kompose "${KOMPOSE_URL}"
RUN chmod +x kompose
Expand All @@ -65,14 +65,14 @@ RUN chmod +x kind

# Download k3d
FROM alpine:3.10 as download-k3d
ENV K3D_VERSION v4.4.6
ENV K3D_VERSION v4.4.7
ENV K3D_URL https://github.com/rancher/k3d/releases/download/${K3D_VERSION}/k3d-linux-amd64
RUN wget -O k3d "${K3D_URL}"
RUN chmod +x k3d

# Download gcloud
FROM alpine:3.10 as download-gcloud
ENV GCLOUD_VERSION 347.0.0
ENV GCLOUD_VERSION 349.0.0
ENV GCLOUD_URL https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${GCLOUD_VERSION}-linux-x86_64.tar.gz
RUN wget -O gcloud.tar.gz "${GCLOUD_URL}"
RUN tar -zxf gcloud.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion docs/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ weight = 1
copyright = "Skaffold Authors"
privacy_policy = "https://policies.google.com/privacy"
github_repo = "https://github.com/GoogleContainerTools/skaffold"
skaffold_version = "skaffold/v2beta20"
skaffold_version = "skaffold/v2beta21"

# Google Custom Search Engine ID. Remove or comment out to disable search.
# gcs_engine_id = "013756393218025596041:3nojel67sum"
Expand Down
1 change: 1 addition & 0 deletions docs/content/en/docs/pipeline-stages/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ will not push artifacts to a remote repository.
| [File Sync]({{< relref "/docs/pipeline-stages/filesync" >}}) | sync changed files directly to containers |
| [Log Tailing]({{< relref "/docs/pipeline-stages/log-tailing" >}}) | tail logs from workloads |
| [Port Forwarding]({{< relref "/docs/pipeline-stages/port-forwarding" >}}) | forward ports from services and arbitrary resources to localhost |
| [Lifecycle Hooks]({{< relref "/docs/pipeline-stages/lifecycle-hooks" >}}) | run code triggered by different events during the skaffold process lifecycle |
| [Cleanup]({{< relref "/docs/pipeline-stages/cleanup" >}}) | cleanup manifests and images |
113 changes: 113 additions & 0 deletions docs/content/en/docs/pipeline-stages/lifecycle-hooks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
title: "Lifecycle Hooks"
linkTitle: "Lifecycle Hooks"
weight: 50
featureId: hooks
aliases: [/docs/how-tos/hooks]
---

This page describes how to use the lifecycle hook framework to run code triggered by different events during the skaffold process lifecycle.

## Overview

We identify three distinct phases in skaffold - `build`, `sync` and `deploy`. Skaffold can trigger a hook `before` or `after` executing each phase. There are two types of `hooks` that can be defined - `host` hooks and `container` hooks.

## Host hooks

Host hooks are executed on the runner and can be defined for the following phases:

### `before-build` and `after-build`

Example: _skaffold.yaml_ snippet
```yaml
build:
artifacts:
- image: hooks-example
hooks:
before:
- command: ["sh", "-c", "./hook.sh"]
os: [darwin, linux]
- command: ["cmd.exe", "/C", "hook.bat"]
os: [windows]
after:
- command: ["sh", "-c", "./hook.sh"]
os: [darwin, linux]
- command: ["cmd.exe", "/C", "hook.bat"]
os: [windows]
```
This config snippet defines that `hook.sh` (for `darwin` or `linux` OS) or `hook.bat` (for `windows` OS) will be executed `before` and `after` each build for artifact `hooks-example`.

### `before-sync` and `after-sync`

Example: _skaffold.yaml_ snippet
```yaml
build:
artifacts:
- image: hooks-example
sync:
auto: {}
hooks:
before:
- host:
command: ["sh", "-c", "./hook.sh"]
os: [darwin, linux]
- host:
command: ["cmd.exe", "/C", "hook.bat"]
os: [windows]
after:
- host:
command: ["sh", "-c", "./hook.sh"]
os: [darwin, linux]
- host:
command: ["cmd.exe", "/C", "hook.bat"]
os: [windows]
```
This config snippet defines that `hook.sh` (for `darwin` or `linux` OS) or `hook.bat` (for `windows` OS) will be executed `before` and `after` each file sync operation for artifact `hooks-example`.

### `before-deploy` and `after-deploy` (_to be implemented_)

### Environment variables

The following environment variables will be available for the corresponding phase host hooks, that can be resolved in both inline commands or scripts.

Environment variable | Description | Availability
-- | -- | --
$SKAFFOLD_IMAGE | The fully qualified image name. For example, “gcr.io/image1:tag” | Build, Sync
$SKAFFOLD_PUSH_IMAGE | Set to true if the image in $IMAGE is expected to exist in a remote registry. Set to false if the image is expected to exist locally. | Build
$SKAFFOLD_IMAGE_REPO | The image repo. For example, “gcr.io/image1” | Build
$SKAFFOLD_IMAGE_TAG | The image tag. For example, “tag” | Build
$SKAFFOLD_BUILD_CONTEXT | An absolute path to the directory this artifact is meant to be built from. Specified by artifact context in the skaffold.yaml. | Build
$SKAFFOLD_FILES_ADDED_OR_MODIFIED | Semi-colon delimited list of absolute path to all files synced or to be synced in current dev loop that have been added or modified | Sync
$SKAFFOLD_FILES_DELETED | Semi-colon delimited list of absolute path to all files synced or to be synced in current dev loop that have been deleted | Sync
$SKAFFOLD_RUN_ID | Run specific UUID label for deployed or to be deployed resources | Deploy
$SKAFFOLD_DEFAULT_REPO | The resolved default repository | All
$SKAFFOLD_RPC_PORT | TCP port to expose event API | All
$SKAFFOLD_HTTP_PORT | TCP port to expose event REST API over HTTP | All
$SKAFFOLD_KUBE_CONTEXT | The resolved Kubernetes context | Sync, Deploy
$SKAFFOLD_NAMESPACES | Comma separated list of Kubernetes namespaces | Sync, Deploy
$SKAFFOLD_WORK_DIR | The workspace root directory | All
Local environment variables | The current state of the local environment (e.g. $HOST, $PATH). Determined by the golang os.Environ function. | All

## Container hooks
Container hooks are executed on a target container and can be defined on the following phases:

### `before-sync` and `after-sync`

Example: _skaffold.yaml_ snippet
```yaml
build:
artifacts:
- image: hooks-example
sync:
auto: {}
hooks:
before:
- container:
command: ["sh", "-c", "echo before sync hook"]
after:
- container:
command: ["sh", "-c", "echo after sync hook"]
```
This config snippet defines a command to run inside the container corresponding to the artifact `hooks-example` image, `before` and `after` each file sync operation.

### `before-deploy` and `after-deploy` (_to be implemented_)
Loading

0 comments on commit b97f8bf

Please sign in to comment.