Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 7eb124e

Browse files
author
Jim Clark
committed
Add docs for Automatic Image Updates
1 parent 7eccaf2 commit 7eb124e

File tree

4 files changed

+106
-5
lines changed

4 files changed

+106
-5
lines changed

docs/getting_started/checks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ curl -X POST \
7575
-d '{"query": "'"$(sed 's/"/\\"/g' < policy.graphql)"'", "variables": '"$(< rules.json)"'}' \
7676
-H "Authorization: Bearer ${ATOMIST_API_KEY}" \
7777
-H "Content-Type: application/json" \
78-
https://automation.atomist.com/graphql/team/${ATOMIST_API_KEY}
78+
https://automation.atomist.com/graphql/team/${ATOMIST_WORKSPACE_ID}
7979
```
8080

8181

docs/getting_started/pull-oriented.md

Lines changed: 104 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1-
## Pull Oriented Delivery
1+
## Automatic Spec Updates
22

3+
### Using the Flux kustomization controller
34

4-
### Using Flux
5+
#### Choose a repository on GitHub
56

6-
Requires environment variables `GITHUB_USER` and `GITHUB_TOKEN`.
7+
Either choose an existing gitops repository, or create a new one. This will be the repository that you'll use to hold
8+
the kubernetes specifications that will be synchronized with your cluster.
9+
10+
You can use a repository in your personal user org, or a GitHub Organization. You'll need the name of the repository, the org name, and
11+
a personal access token with enough scope to access the repository.
12+
13+
```
14+
GITHUB_USER=<org-or-user-name>
15+
GITHUB_TOKEN=<personal access token?
16+
GITHUB_REPO=<repo-name>
17+
```
18+
19+
#### Install flux in your cluster
20+
21+
Requires environment variables `GITHUB_USER` and `GITHUB_TOKEN` to be set. Use the `--personal` flag if you're using your personal org but
22+
leave this flag out if you're using a shared GitHub organization.
723

824
```bash
925
flux bootstrap github \
@@ -13,3 +29,88 @@ flux bootstrap github \
1329
--path=./clusters/my-cluster \
1430
--personal
1531
```
32+
33+
#### Add at least one kustomization.yaml file
34+
35+
In a typical scenario, we are looking for candidate images that are _ready_ to
36+
be pulled into the cluster. A kubernetes deployment spec would have an entry that looks
37+
like this.
38+
39+
```yaml
40+
spec:
41+
containers:
42+
- image: gcr.io/personalsdm-216019/altjserver
43+
```
44+
45+
A `kustomization.yaml` that references this `deployment.yaml` file can update the `newTag` entry whenever
46+
a new Image is ready.
47+
48+
```yaml
49+
apiVersion: kustomize.config.k8s.io/v1beta1
50+
kind: Kustomization
51+
namespace: production
52+
resources:
53+
- deployment.yaml
54+
images:
55+
- name: gcr.io/personalsdm-216019/altjserver
56+
newTag: v161
57+
```
58+
59+
In this example, an image from a repository named `gcr.io/personalsdm-216019/altjserver` can now be updated
60+
via the flux kustomization controller.
61+
62+
#### Configure automatic updates for this git repository
63+
64+
Now that Flux is monitoring this kustomizations, any updates to the `kustomization.yaml` file in the default
65+
branch ref, will be synchronized by your cluster.
66+
67+
Every repository containing updateable kustomization.yaml files must
68+
be included in the array of repo slugs. Create a json file (e.g. repos.json)
69+
and record the names of any gitops repos containing kustomization.yaml
70+
files you might want to automatically update.
71+
72+
```bash
73+
cat <<'EOF' > repos.json
74+
{"repos": ["user-or-org/repos-name"]}
75+
EOF
76+
```
77+
78+
Now execute the scripts below to enable the automatic updates:
79+
80+
```bash
81+
ATOMIST_WORKSPACE_ID=<workspace-id>
82+
ATOMIST_API_KEY=<api-key>
83+
```
84+
85+
* `workspace-id`
86+
* Grab your workspace ID from [the Integrations tab](https://dso.atomist.com/r/auth/integrations)
87+
* `api-key`
88+
* Used to authenticate with the Atomist API and managed in [the Integrations tab](https://dso.atomist.com/r/auth/integrations)
89+
90+
![api-access](../img/getting-started/api-access.png)
91+
92+
```bash
93+
cat <<'EOF' > policy.graphql
94+
mutation setPolicy($rules: [String!]!) {
95+
setConfigurationParameter(
96+
name: "deploy-integration",
97+
namespace: "atomist",
98+
parameter: {stringArray:
99+
{name: "gitops-repos",
100+
value: $repos},
101+
configurationName: "policy-cfg")
102+
{
103+
configured {
104+
skills {id}
105+
}
106+
}
107+
}
108+
EOF
109+
110+
curl -X POST \
111+
-d '{"query": "'"$(sed 's/"/\\"/g' < policy.graphql)"'", "variables": '"$(< repos.json)"'}' \
112+
-H "Authorization: Bearer ${ATOMIST_API_KEY}" \
113+
-H "Content-Type: application/json" \
114+
https://automation.atomist.com/graphql/team/${ATOMIST_WORKSPACE_ID}
115+
```
116+
75.6 KB
Loading

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ nav:
4444
- Image Checks: getting_started/checks.md
4545
- Add Slack Notifications: integration/slack.md
4646
- Creating Advisories: getting_started/private-advisories.md
47-
# - Gitops (pull-oriented delivery): getting_started/pull-oriented.md
4847
- Kubernetes Admission Control: integration/kubernetes.md
4948
- Add secret scanning: getting_started/add-secret-scanner-check.md
49+
- Gitops (pull-oriented delivery): getting_started/pull-oriented.md
5050
# - Adding Falco: getting_started/falco.md
5151

5252
# - Policies:

0 commit comments

Comments
 (0)