Skip to content

Commit

Permalink
Merge pull request #3112 from martinhoefling/profile-composability-docs
Browse files Browse the repository at this point in the history
document activation of multiple profiles
  • Loading branch information
balopat authored Oct 31, 2019
2 parents d685e42 + 09c00b9 commit 3f4de94
Show file tree
Hide file tree
Showing 23 changed files with 299 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/content/en/docs/environment/profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,14 @@ In the example below instead of overriding the whole `build` section, the `dev`
defines a different Dockerfile to use for the first artifact.

{{% readfile file="samples/profiles/patches.yaml" %}}

### Activating multiple profiles at the same time

Multiple profiles can be specified either by using the `-p` flag multiple times or by comma separated profiles.

```bash
skaffold dev -p hello,world
```

Skaffold will activate both profiles, `hello` and `world`.
This is e.g. useful when combined with patches to provide a composable development setup where `hello` and `world` can be added on demand.
23 changes: 23 additions & 0 deletions examples/profile-patches/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
=== Example: Getting started with a simple go app
:icons: font

This is a simple show-case of how Skaffold profiles can be patched.
Patched profiles e.g. can be used in development to provide a composable development setup.
Here, a "base" service is always started. Two additional services "hello" and "world" can be activated via profiles.

==== Init
Use the `--profile` option to add profiles `skaffold dev --profile hello,world`

==== Workflow
* Build only the `base-service` when using the main profile
* Build `hello` and/or `world` when specified via `-p` flag. Multiple `-p` flags are supported as well as comma separated values.

ifndef::env-github[]
==== link:{github-repo-tree}/examples/profiles[Example files icon:github[]]

[source,yaml, indent=3, title=skaffold.yaml]
----
include::skaffold.yaml[]
----

endif::[]
7 changes: 7 additions & 0 deletions examples/profile-patches/base-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM golang:1.12.9-alpine3.10 as builder
COPY main.go .
RUN go build -o /app main.go

FROM alpine:3.10
CMD ["./app"]
COPY --from=builder /app .
8 changes: 8 additions & 0 deletions examples/profile-patches/base-service/k8s-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Pod
metadata:
name: base-service
spec:
containers:
- name: base-service
image: gcr.io/k8s-skaffold/skaffold-base
14 changes: 14 additions & 0 deletions examples/profile-patches/base-service/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
"fmt"
"time"
)

func main() {
for {
fmt.Println("BASE")

time.Sleep(time.Second * 1)
}
}
7 changes: 7 additions & 0 deletions examples/profile-patches/hello-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM golang:1.12.9-alpine3.10 as builder
COPY main.go .
RUN go build -o /app main.go

FROM alpine:3.10
CMD ["./app"]
COPY --from=builder /app .
8 changes: 8 additions & 0 deletions examples/profile-patches/hello-service/k8s-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Pod
metadata:
name: hello-service
spec:
containers:
- name: hello-service
image: gcr.io/k8s-skaffold/skaffold-hello
14 changes: 14 additions & 0 deletions examples/profile-patches/hello-service/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
"fmt"
"time"
)

func main() {
for {
fmt.Println("HELLO")

time.Sleep(time.Second * 1)
}
}
34 changes: 34 additions & 0 deletions examples/profile-patches/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: skaffold/v1beta16
kind: Config
build:
# only build and deploy "base-service" on main profile
artifacts:
- image: gcr.io/k8s-skaffold/skaffold-base
context: base-service
deploy:
kubectl:
manifests:
- 'base-service/*.yaml'

profiles:
- name: hello
patches:
- op: add
path: /build/artifacts/1
value:
image: gcr.io/k8s-skaffold/skaffold-hello
context: hello-service
- op: add
path: /deploy/kubectl/manifests/1
value: 'hello-service/*.yaml'

- name: world
patches:
- op: add
path: /build/artifacts/1
value:
image: gcr.io/k8s-skaffold/skaffold-world
context: world-service
- op: add
path: /deploy/kubectl/manifests/1
value: 'world-service/*.yaml'
7 changes: 7 additions & 0 deletions examples/profile-patches/world-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM golang:1.12.9-alpine3.10 as builder
COPY main.go .
RUN go build -o /app main.go

FROM alpine:3.10
CMD ["./app"]
COPY --from=builder /app .
8 changes: 8 additions & 0 deletions examples/profile-patches/world-service/k8s-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Pod
metadata:
name: world-service
spec:
containers:
- name: world-service
image: gcr.io/k8s-skaffold/skaffold-world
14 changes: 14 additions & 0 deletions examples/profile-patches/world-service/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
"fmt"
"time"
)

func main() {
for {
fmt.Println("WORLD")

time.Sleep(time.Second * 1)
}
}
23 changes: 23 additions & 0 deletions integration/examples/profile-patches/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
=== Example: Getting started with a simple go app
:icons: font

This is a simple show-case of how Skaffold profiles can be patched.
Patched profiles e.g. can be used in development to provide a composable development setup.
Here, a "base" service is always started. Two additional services "hello" and "world" can be activated via profiles.

==== Init
Use the `--profile` option to add profiles `skaffold dev --profile hello,world`

==== Workflow
* Build only the `base-service` when using the main profile
* Build `hello` and/or `world` when specified via `-p` flag. Multiple `-p` flags are supported as well as comma separated values.

ifndef::env-github[]
==== link:{github-repo-tree}/examples/profiles[Example files icon:github[]]

[source,yaml, indent=3, title=skaffold.yaml]
----
include::skaffold.yaml[]
----

endif::[]
7 changes: 7 additions & 0 deletions integration/examples/profile-patches/base-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM golang:1.12.9-alpine3.10 as builder
COPY main.go .
RUN go build -o /app main.go

FROM alpine:3.10
CMD ["./app"]
COPY --from=builder /app .
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Pod
metadata:
name: base-service
spec:
containers:
- name: base-service
image: gcr.io/k8s-skaffold/skaffold-base
14 changes: 14 additions & 0 deletions integration/examples/profile-patches/base-service/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
"fmt"
"time"
)

func main() {
for {
fmt.Println("BASE")

time.Sleep(time.Second * 1)
}
}
7 changes: 7 additions & 0 deletions integration/examples/profile-patches/hello-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM golang:1.12.9-alpine3.10 as builder
COPY main.go .
RUN go build -o /app main.go

FROM alpine:3.10
CMD ["./app"]
COPY --from=builder /app .
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Pod
metadata:
name: hello-service
spec:
containers:
- name: hello-service
image: gcr.io/k8s-skaffold/skaffold-hello
14 changes: 14 additions & 0 deletions integration/examples/profile-patches/hello-service/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
"fmt"
"time"
)

func main() {
for {
fmt.Println("HELLO")

time.Sleep(time.Second * 1)
}
}
34 changes: 34 additions & 0 deletions integration/examples/profile-patches/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: skaffold/v1beta16
kind: Config
build:
# only build and deploy "base-service" on main profile
artifacts:
- image: gcr.io/k8s-skaffold/skaffold-base
context: base-service
deploy:
kubectl:
manifests:
- 'base-service/*.yaml'

profiles:
- name: hello
patches:
- op: add
path: /build/artifacts/1
value:
image: gcr.io/k8s-skaffold/skaffold-hello
context: hello-service
- op: add
path: /deploy/kubectl/manifests/1
value: 'hello-service/*.yaml'

- name: world
patches:
- op: add
path: /build/artifacts/1
value:
image: gcr.io/k8s-skaffold/skaffold-world
context: world-service
- op: add
path: /deploy/kubectl/manifests/1
value: 'world-service/*.yaml'
7 changes: 7 additions & 0 deletions integration/examples/profile-patches/world-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM golang:1.12.9-alpine3.10 as builder
COPY main.go .
RUN go build -o /app main.go

FROM alpine:3.10
CMD ["./app"]
COPY --from=builder /app .
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Pod
metadata:
name: world-service
spec:
containers:
- name: world-service
image: gcr.io/k8s-skaffold/skaffold-world
14 changes: 14 additions & 0 deletions integration/examples/profile-patches/world-service/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
"fmt"
"time"
)

func main() {
for {
fmt.Println("WORLD")

time.Sleep(time.Second * 1)
}
}

0 comments on commit 3f4de94

Please sign in to comment.