Skip to content

Commit

Permalink
Merge pull request #2134 from monopole/moveStatusToKustomize
Browse files Browse the repository at this point in the history
Move status command to kustomize.
  • Loading branch information
monopole authored Jan 22, 2020
2 parents 39c7a06 + 8e5bce1 commit c7d7897
Show file tree
Hide file tree
Showing 29 changed files with 119 additions and 649 deletions.
9 changes: 8 additions & 1 deletion .golangci-kustomize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ linters:
- bodyclose
- deadcode
- depguard
# - dogsled
- dupl
# - errcheck
# - funlen
# - gochecknoinits
- goconst
# - gocritic
- gocyclo
- gofmt
- goimports
Expand All @@ -21,16 +26,18 @@ linters:
- lll
- misspell
- nakedret
# - scopelint
- staticcheck
- structcheck
# stylecheck demands that acronyms not be treated as words
# in camelCase, so JsonOp become JSONOp, etc. Yuck.
# - stylecheck
- typecheck
- unconvert
- unused
- unparam
- unused
- varcheck
# - whitespace

linters-settings:
dupl:
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ test-examples-e2e-kustomize: $(MYGOBIN)/mdrip $(MYGOBIN)/kind
/bin/rm -f $(MYGOBIN)/kustomize; \
echo "Installing kustomize from ."; \
cd kustomize; go install .; cd ..; \
echo "Installing resource from ."; \
cd cmd/resource; go install .; cd ../..; \
./hack/testExamplesE2EAgainstKustomize.sh .; \
)

Expand Down
2 changes: 0 additions & 2 deletions cmd/resource/LICENSE_TEMPLATE

This file was deleted.

39 changes: 0 additions & 39 deletions cmd/resource/Makefile

This file was deleted.

20 changes: 0 additions & 20 deletions cmd/resource/fixgomod.sh

This file was deleted.

21 changes: 0 additions & 21 deletions cmd/resource/go.mod

This file was deleted.

444 changes: 0 additions & 444 deletions cmd/resource/go.sum

This file was deleted.

29 changes: 0 additions & 29 deletions cmd/resource/main.go

This file was deleted.

24 changes: 0 additions & 24 deletions cmd/resource/status/status.go

This file was deleted.

43 changes: 20 additions & 23 deletions examples/alphaTestExamples/MultipleDeployments.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Alternatively, use
```
BASE=$DEMO_HOME/base
mkdir -p $BASE
OUTPUT=$DEMO_HOME/output
mkdir -p $OUTPUT

mkdir $BASE/wordpress
mkdir $BASE/mysql
Expand Down Expand Up @@ -59,51 +61,46 @@ metadata:
EOF
```
<!-- @setGoBin @testE2EAgainstLatestRelease -->
```
MYGOBIN=$GOPATH/bin
```
Delete any existing kind cluster and create a new one. By default the name of the cluster is "kind"
<!-- @deleteAndCreateKindCluster @testE2EAgainstLatestRelease -->
```
$MYGOBIN/kind delete cluster;
$MYGOBIN/kind create cluster;
kind delete cluster
kind create cluster
```
Let's run the wordpress and mysql services.
<!-- @RunWordpressAndMysql @testE2EAgainstLatestRelease -->
```
export KUSTOMIZE_ENABLE_ALPHA_COMMANDS=true

$MYGOBIN/kustomize resources apply $BASE/mysql --status;
kustomize resources apply $BASE/mysql --status;

status=$(mktemp);
$MYGOBIN/resource status fetch $BASE/mysql > $status
kustomize status fetch $BASE/mysql > $OUTPUT/status

test 1 == \
$(grep "mysql" $status | grep "Deployment is available. Replicas: 1" | wc -l); \
$(grep "mysql" $OUTPUT/status | grep "Deployment is available. Replicas: 1" | wc -l); \
echo $?

test 1 == \
$(grep "mysql-pass" $status | grep "Resource is always ready" | wc -l); \
$(grep "mysql-pass" $OUTPUT/status | grep "Resource is always ready" | wc -l); \
echo $?

test 1 == \
$(grep "mysql" $status | grep "Service is ready" | wc -l); \
$(grep "mysql" $OUTPUT/status | grep "Service is ready" | wc -l); \
echo $?

$MYGOBIN/kustomize resources apply $BASE/wordpress --status;
kustomize resources apply $BASE/wordpress --status;

status=$(mktemp);
$MYGOBIN/resource status fetch $BASE/wordpress > $status
kustomize status fetch $BASE/wordpress > $OUTPUT/status

test 1 == \
$(grep "wordpress" $status | grep "Deployment is available. Replicas: 1" | wc -l); \
$(grep "wordpress" $OUTPUT/status | grep "Deployment is available. Replicas: 1" | wc -l); \
echo $?

test 1 == \
$(grep "wordpress" $status | grep "Service is ready" | wc -l); \
$(grep "wordpress" $OUTPUT/status | grep "Service is ready" | wc -l); \
echo $?
```
Expand All @@ -130,26 +127,26 @@ sed -i.bak 's/secret/secret2/' \
sed -i.bak 's/mysql-pass/mysql-pass2/' \
$BASE/mysql/deployment.yaml

$MYGOBIN/kustomize resources apply $BASE/mysql --status;
kustomize resources apply $BASE/mysql --status;

status=$(mktemp);
$MYGOBIN/resource status fetch $BASE/mysql > $status
kustomize status fetch $BASE/mysql > $OUTPUT/status

test 1 == \
$(grep "mysql" $status | grep "Deployment is available. Replicas: 1" | wc -l); \
$(grep "mysql" $OUTPUT/status | grep "Deployment is available. Replicas: 1" | wc -l); \
echo $?

test 1 == \
$(grep "mysql-pass2" $status | grep "Resource is always ready" | wc -l); \
$(grep "mysql-pass2" $OUTPUT/status | grep "Resource is always ready" | wc -l); \
echo $?

test 1 == \
$(grep "mysql" $status | grep "Service is ready" | wc -l); \
$(grep "mysql" $OUTPUT/status | grep "Service is ready" | wc -l); \
echo $?
```
Clean-up the cluster
<!-- @deleteKindCluster @testE2EAgainstLatestRelease -->
```
$MYGOBIN/kind delete cluster;
```
kind delete cluster
```
39 changes: 17 additions & 22 deletions examples/alphaTestExamples/helloapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Let's run the [hello] service.
```
BASE=$DEMO_HOME/base
mkdir -p $BASE
OUTPUT=$DEMO_HOME/output
mkdir -p $OUTPUT
```
Now lets add a simple config map resource to the `base`
Expand Down Expand Up @@ -158,40 +160,34 @@ sed -i.bak 's/app: hello/app: my-hello/' \
$BASE/kustomization.yaml
```
To do end to end tests using kustomize on local, go through the following section. You should have GOPATH set up and [kind] installed.
<!-- @setGoBin @testE2EAgainstLatestRelease -->
```
MYGOBIN=$GOPATH/bin
```
The following requires installation of [kind].
Delete any existing kind cluster and create a new one. By default the name of the cluster is "kind"
<!-- @deleteAndCreateKindCluster @testE2EAgainstLatestRelease -->
```
$MYGOBIN/kind delete cluster;
$MYGOBIN/kind create cluster;
kind delete cluster
kind create cluster
```
Use the kustomize binary in MYGOBIN to apply a deployment, fetch the status and verify the status.
<!-- @runHelloApp @testE2EAgainstLatestRelease -->
```
export KUSTOMIZE_ENABLE_ALPHA_COMMANDS=true

$MYGOBIN/kustomize resources apply $BASE --status;
kustomize resources apply $BASE --status;

status=$(mktemp);
$MYGOBIN/resource status fetch $BASE > $status
kustomize status fetch $BASE > $OUTPUT/status

test 1 == \
$(grep "the-deployment" $status | grep "Deployment is available. Replicas: 3" | wc -l); \
$(grep "the-deployment" $OUTPUT/status | grep "Deployment is available. Replicas: 3" | wc -l); \
echo $?

test 1 == \
$(grep "the-map" $status | grep "Resource is always ready" | wc -l); \
$(grep "the-map" $OUTPUT/status | grep "Resource is always ready" | wc -l); \
echo $?

test 1 == \
$(grep "the-service" $status | grep "Service is ready" | wc -l); \
$(grep "the-service" $OUTPUT/status | grep "Service is ready" | wc -l); \
echo $?
```
Expand All @@ -216,30 +212,29 @@ sed -i.bak 's/configMap/configMap2/' \
sed -i.bak 's/the-map/the-map2/' \
$BASE/deployment.yaml

$MYGOBIN/kustomize resources apply $BASE --status;
kustomize resources apply $BASE --status;

status=$(mktemp);
$MYGOBIN/resource status fetch $BASE > $status
$MYGOBIN/resource status fetch $BASE > /tmp/teste2eout/out.txt
kustomize status fetch $BASE > $OUTPUT/status

test 1 == \
$(grep "the-deployment" $status | grep "Deployment is available. Replicas: 3" | wc -l); \
$(grep "the-deployment" $OUTPUT/status | grep "Deployment is available. Replicas: 3" | wc -l); \
echo $?

test 1 == \
$(grep "the-map2" $status | grep "Resource is always ready" | wc -l); \
$(grep "the-map2" $OUTPUT/status | grep "Resource is always ready" | wc -l); \
echo $?

test 1 == \
$(grep "the-service" $status | grep "Service is ready" | wc -l); \
$(grep "the-service" $OUTPUT/status | grep "Service is ready" | wc -l); \
echo $?
```
Clean-up the cluster
<!-- @deleteKindCluster @testE2EAgainstLatestRelease -->
```
$MYGOBIN/kind delete cluster;
kind delete cluster
```
### Next Exercise
Create overlays as described in the [helloWorld] section and verify the results. Good luck!
Create overlays as described in the [helloWorld] section and verify the results.
Loading

0 comments on commit c7d7897

Please sign in to comment.