Skip to content

Commit

Permalink
added path documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonrichardsmith committed Mar 19, 2020
1 parent 52eff36 commit 22dbbbb
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 0 deletions.
115 changes: 115 additions & 0 deletions PATH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Setting The Path

We will now try setting the path value.

The path will be explicitly called from what you set like any
[kustomize url](https://github.com/kubernetes-sigs/kustomize/blob/master/examples/remoteBuild.md).

In previous examples we were deploying a Deployment, Service and ConfigMap

In the branch
["path" on the examples repo](https://github.com/slipway-gitops/slipway-example-app/blob/path/kustomize/base/kustomization.yaml)
the Service has been removed.

```yaml
commonLabels:
app: hello

resources:
- deployment.yaml
- configMap.yaml
```
We will insure we are not running and gitrepo-samples at this time
```bash
$ kubectl delete gitrep gitrepo-sample
```

Now we will deploy the same basic deployment we used before but explicitly set the path to the "path" branch

```
apiVersion: git.gitops.slipway.org/v1
kind: GitRepo
metadata:
name: gitrepo-sample
spec:
uri: "[email protected]:slipway-gitops/slipway-example-app.git"
operations:
- operation: test
path: "[email protected]:slipway-gitops/slipway-example-app.git//kustomize/base?ref=path"
weight: 3
optype: branch
reference: master
```
We will now apply this manifest
```bash
$ kubectl apply -f path-url.yaml
gitrepo.git.gitops.slipway.org/gitrepo-sample configured
```
Now if we check all the resources that were deployed.
```bash
$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/the-deployment-7fd7749979-7tcjj 1/1 Running 0 50m
pod/the-deployment-7fd7749979-89p7j 1/1 Running 0 50m
pod/the-deployment-7fd7749979-scqp7 1/1 Running 0 50m

NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/the-deployment 3/3 3 3 50m

NAME DESIRED CURRENT READY AGE
replicaset.apps/the-deployment-7fd7749979 3 3 3 50m
```

We can see the Service was not deployed.

Explicitly setting the path is one option.
Another option is using the commit hash you are currently working on.

## HashPath
Using the same basic example we will set hash path to true. and change the branch
to "path". So we are now matching the "path" branch but using the regular path.
Normally this would deploy all three services but because we have set "hashpath"
It will automatically append "?ref=yourhashhere" to the deployment.

```yaml
apiVersion: git.gitops.slipway.org/v1
kind: GitRepo
metadata:
name: gitrepo-sample
spec:
uri: "[email protected]:slipway-gitops/slipway-example-app.git"
operations:
- operation: test
path: "[email protected]:slipway-gitops/slipway-example-app.git//kustomize/base"
weight: 3
hashpath: true
optype: branch
reference: path
```
We will apply this.
```bash
$ kubectl apply -f path-url.yaml
gitrepo.git.gitops.slipway.org/gitrepo-sample configured
```
First we may notice the deployed has is different.
```
$ kubectl get hash
NAME AGE
abb5f4faacac21c1ebf0d50b20666842b19aeab0 6s
```

We are no longer using the master branch reference, but the
[hash to the last commit of the "path" branch.](https://github.com/slipway-gitops/slipway-example-app/commit/abb5f4faacac21c1ebf0d50b20666842b19aeab0)

You will also notice we still have not deployed the Service, because under that commit
It is not set.

Given these two options, you can explicitly set kustomize to deploy explicitly in the
same way everytime or you can have it behave contextually to your commit.

Tear it down.
```bash
$ kubectl delete gitrep gitrepo-sample
```
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ All examples will be using the [slipway-example-app](https://github.com/slipway-

- [Basic Example](BASIC.md)
- [Regex for References](REGEX.md)
- [Setting the Path](PATH.md)
13 changes: 13 additions & 0 deletions path-hash.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: git.gitops.slipway.org/v1
kind: GitRepo
metadata:
name: gitrepo-sample
spec:
uri: "[email protected]:slipway-gitops/slipway-example-app.git"
operations:
- operation: test
path: "[email protected]:slipway-gitops/slipway-example-app.git//kustomize/base"
weight: 3
hashpath: true
optype: branch
reference: path
12 changes: 12 additions & 0 deletions path-url.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: git.gitops.slipway.org/v1
kind: GitRepo
metadata:
name: gitrepo-sample
spec:
uri: "[email protected]:slipway-gitops/slipway-example-app.git"
operations:
- operation: test
path: "[email protected]:slipway-gitops/slipway-example-app.git//kustomize/base?ref=path"
weight: 3
optype: branch
reference: master

0 comments on commit 22dbbbb

Please sign in to comment.