Skip to content

Commit

Permalink
Merge pull request #38 from turkenh/release-0.3.3
Browse files Browse the repository at this point in the history
Release 0.3.3
  • Loading branch information
turkenh authored Oct 21, 2020
2 parents 286fe4c + 6c3fed8 commit 1a41860
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 35 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ GO111MODULE = on

# ====================================================================================
# Setup Kubernetes tools

KIND_VERSION = v0.7.0
USE_HELM3 = true
-include build/makelib/k8s_tools.mk

# ====================================================================================
Expand Down Expand Up @@ -103,7 +104,7 @@ submodules:
# try running the binary directly with different arguments.
run: $(KUBECTL) generate
@$(INFO) Running Crossplane locally out-of-cluster . . .
@$(KUBECTL) apply -f config/crd/ -R
@$(KUBECTL) apply -f package/crds/ -R
go run cmd/provider/main.go -d

manifests:
Expand Down
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,35 @@ make run
Since controller is running outside of the Kind cluster, you need to make api server accessible (on a separate terminal):
```
sudo kubectl proxy --port=80
sudo kubectl proxy --port=8081
```
### Testing in Local Cluster
1. Deploy [RBAC for local cluster](examples/provider-config/local-service-account.yaml)
1. Prepare KUBECONFIG for local cluster:
1. If helm provider running in cluster (e.g. provider installed with crossplane):
```
KUBECONFIG=$(kind get kubeconfig --name local-dev | sed -e 's|server:\s*.*$|server: https://kubernetes.default.svc|g')
```
1. If provider helm running outside of the cluster (e.g. running locally with `make run`)
```
KUBECONFIG=$(kind get kubeconfig --name local-dev | sed -e 's|server:\s*.*$|server: http://localhost:8081|g')
```
1. Create KUBECONFIG secret for local cluster and deploy [local-provider.yaml](examples/provider-config/local-provider-config.yaml).
```
kubectl apply -f examples/provider-config/local-service-account.yaml
kubectl -n crossplane-system create secret generic local-cluster --from-literal=kubeconfig="${KUBECONFIG}"
kubectl apply -f examples/provider-config/local-provider-config.yaml
```
1. Deploy [local-provider.yaml](examples/provider-config/local-provider-config.yaml) by replacing `spec.credentialsSecretRef.name` with the token secret name.
1. Now you can create `Release` resources with provider reference, see [sample release.yaml](examples/sample/release.yaml).
```
EXP="s/<helm-provider-token-secret-name>/$(kubectl get sa helm-provider -n crossplane-system -o jsonpath="{.secrets[0].name}")/g"
cat examples/provider-config/local-provider-config.yaml | sed -e "${EXP}" | kubectl apply -f -
kubectl create -f examples/sample/release.yaml
```
1. Now you can create `Release` resources with provider reference, see [sample release.yaml](examples/sample/release.yaml).
### Cleanup
Expand Down
2 changes: 1 addition & 1 deletion build
2 changes: 2 additions & 0 deletions cluster/images/provider-helm-controller/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ RUN apk --no-cache add ca-certificates bash

ADD provider /usr/local/bin/crossplane-helm-provider

ENV XDG_CACHE_HOME /tmp

EXPOSE 8080
USER 1001
ENTRYPOINT ["crossplane-helm-provider"]
2 changes: 1 addition & 1 deletion cluster/local/kind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.16.9
image: kindest/node:v1.17.11
8 changes: 3 additions & 5 deletions examples/provider-config/local-provider-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ metadata:
name: local-provider-config
spec:
credentials:
source: Secret
source: Secret
secretRef:
# Get secret name from service account
name: <helm-provider-token-secret-name>
name: local-cluster
namespace: crossplane-system
# We rely on multiple keys in ProviderConfig secret, so, ignoring "spec.credentialsSecretRef.key"
key: ignore
key: kubeconfig
18 changes: 0 additions & 18 deletions examples/provider-config/local-service-account.yaml

This file was deleted.

5 changes: 4 additions & 1 deletion pkg/controller/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,10 @@ func (e *helmExternal) Delete(_ context.Context, mg resource.Managed) error {
}

func shouldRollBack(cr *v1alpha1.Release) bool {
return cr.Status.Synced && cr.Status.AtProvider.State == release.StatusFailed && rollBackEnabled(cr)
return rollBackEnabled(cr) &&
((cr.Status.Synced && cr.Status.AtProvider.State == release.StatusFailed) ||
(cr.Status.AtProvider.State == release.StatusPendingInstall) ||
(cr.Status.AtProvider.State == release.StatusPendingUpgrade))
}

func rollBackEnabled(cr *v1alpha1.Release) bool {
Expand Down

0 comments on commit 1a41860

Please sign in to comment.