1
- ## Pull Oriented Delivery
1
+ ## Automatic Spec Updates
2
2
3
+ ### Using the Flux kustomization controller
3
4
4
- ### Using Flux
5
+ #### Choose a repository on GitHub
5
6
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.
7
23
8
24
``` bash
9
25
flux bootstrap github \
@@ -13,3 +29,88 @@ flux bootstrap github \
13
29
--path=./clusters/my-cluster \
14
30
--personal
15
31
```
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
+ 
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
+
0 commit comments