Skip to content

Commit 410d758

Browse files
authored
Merge pull request #273 from vignesh-goutham/v1beta3-main-sync
Sync main changes to v1beta3
2 parents f1e4902 + ff094da commit 410d758

File tree

33 files changed

+499
-140
lines changed

33 files changed

+499
-140
lines changed

Makefile

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ DEEPCOPY_GEN_INPUTS=$(shell find ./api -name "*test*" -prune -o -name "*zz_gener
149149
.PHONY: generate-deepcopy
150150
generate-deepcopy: $(DEEPCOPY_GEN_TARGETS) ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
151151
api/%/zz_generated.deepcopy.go: $(CONTROLLER_GEN) $(DEEPCOPY_GEN_INPUTS)
152-
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
152+
CGO_ENABLED=0 $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
153153

154154
MANIFEST_GEN_INPUTS=$(shell find ./api ./controllers -type f -name "*test*" -prune -o -name "*zz_generated*" -prune -o -print)
155155
# Using a flag file here as config output is too complicated to be a target.
@@ -237,7 +237,7 @@ kind-cluster: cluster-api ## Create a kind cluster with a local Docker repositor
237237
./cluster-api/hack/kind-install-for-capd.sh
238238

239239
cluster-api: ## Clone cluster-api repository for tilt use.
240-
git clone --branch v1.2.11 --depth 1 https://github.com/kubernetes-sigs/cluster-api.git
240+
git clone --branch v1.2.12 --depth 1 https://github.com/kubernetes-sigs/cluster-api.git
241241

242242
cluster-api/tilt-settings.json: hack/tilt-settings.json cluster-api
243243
cp ./hack/tilt-settings.json cluster-api
@@ -263,13 +263,14 @@ config/.flag-test.mk: $(CONTROLLER_GEN) $(MANIFEST_GEN_INPUTS_TEST)
263263
@touch config/.flag-test.mk
264264

265265
.PHONY: test
266-
test: generate-deepcopy-test generate-manifest-test generate-mocks lint $(GINKGO_V2) $(KUBECTL) $(API_SERVER) $(ETCD) ## Run tests. At the moment this is only unit tests.
266+
test: ## Run tests.
267+
test: generate-deepcopy-test generate-manifest-test generate-mocks lint $(GINKGO_V2) $(KUBECTL) $(API_SERVER) $(ETCD)
267268
@./hack/testing_ginkgo_recover_statements.sh --add # Add ginkgo.GinkgoRecover() statements to controllers.
268269
@# The following is a slightly funky way to make sure the ginkgo statements are removed regardless the test results.
269270
@$(GINKGO_V2) --label-filter="!integ" --cover -coverprofile cover.out --covermode=atomic -v ./api/... ./controllers/... ./pkg/...; EXIT_STATUS=$$?;\
270271
./hack/testing_ginkgo_recover_statements.sh --remove; exit $$EXIT_STATUS
271272

272-
CLUSTER_TEMPLATES_INPUT_FILES=$(shell find test/e2e/data/infrastructure-cloudstack/v1beta*/*/cluster-template* test/e2e/data/infrastructure-cloudstack/*/bases/* -type f)
273+
CLUSTER_TEMPLATES_INPUT_FILES=$(shell find test/e2e/data/infrastructure-cloudstack/v1beta*/cluster-template* test/e2e/data/infrastructure-cloudstack/*/bases/* -type f)
273274
CLUSTER_TEMPLATES_OUTPUT_FILES=$(shell find test/e2e/data/infrastructure-cloudstack -type d -name "cluster-template*" -exec echo {}.yaml \;)
274275
.PHONY: e2e-cluster-templates
275276
e2e-cluster-templates: $(CLUSTER_TEMPLATES_OUTPUT_FILES) ## Generate cluster template files for e2e testing.
@@ -288,7 +289,14 @@ run-e2e: e2e-essentials ## Run e2e testing. JOB is an optional REGEXP to select
288289
-e2e.artifacts-folder=${REPO_ROOT}/_artifacts \
289290
-e2e.config=${E2E_CONFIG} \
290291
-e2e.skip-resource-cleanup=false -e2e.use-existing-cluster=true
292+
EXIT_STATUS=$$?
291293
kind delete clusters capi-test
294+
exit $$EXIT_STATUS
295+
296+
run-e2e-smoke:
297+
./hack/ensure-kind.sh
298+
./hack/ensure-cloud-config-yaml.sh
299+
JOB="\"CAPC E2E SMOKE TEST\"" $(MAKE) run-e2e
292300

293301
##@ Cleanup
294302
## --------------------------------------
@@ -302,6 +310,7 @@ clean: ## Cleans up everything.
302310
rm -rf $(TOOLS_BIN_DIR)
303311
rm -rf cluster-api
304312
rm -rf test/e2e/data/infrastructure-cloudstack/*/*yaml
313+
rm -rf config/.flag.mk config/.flag-test.mk .dockerflag.mk
305314

306315
##@ Release
307316
## --------------------------------------
@@ -336,7 +345,8 @@ release-alias-tag: # Adds the tag to the last build tag.
336345
gcloud container images add-tag -q $(CONTROLLER_IMG):$(TAG) $(CONTROLLER_IMG):$(RELEASE_ALIAS_TAG)
337346

338347
.PHONY: release-templates
339-
release-templates: $(RELEASE_DIR) ## Generate release templates
348+
release-templates: ## Generate release templates
349+
@mkdir -p $(RELEASE_DIR)
340350
cp templates/cluster-template*.yaml $(RELEASE_DIR)/
341351

342352
.PHONY: upload-staging-artifacts

OWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ approvers:
44
- jweite-amazon
55
- dims
66
- g-gaston
7+
- chrisdoherty4
8+
- weizhouapache

api/v1beta2/cloudstackmachine_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ type CloudStackMachineSpec struct {
9292
UncompressedUserData *bool `json:"uncompressedUserData,omitempty"`
9393
}
9494

95+
func (c *CloudStackMachine) CompressUserdata() bool {
96+
return c.Spec.UncompressedUserData == nil || !*c.Spec.UncompressedUserData
97+
}
98+
9599
type CloudStackResourceIdentifier struct {
96100
// Cloudstack resource ID.
97101
// +optional
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
Copyright 2022 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta2_test
18+
19+
import (
20+
"k8s.io/utils/pointer"
21+
capcv1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta2"
22+
23+
. "github.com/onsi/ginkgo/v2"
24+
. "github.com/onsi/gomega"
25+
)
26+
27+
var _ = Describe("CloudStackMachineConfig_CompressUserdata", func() {
28+
for _, tc := range []struct {
29+
Name string
30+
Machine capcv1.CloudStackMachine
31+
Expect bool
32+
}{
33+
{
34+
Name: "is true when uncompressed user data is nil",
35+
Machine: capcv1.CloudStackMachine{
36+
Spec: capcv1.CloudStackMachineSpec{
37+
UncompressedUserData: nil,
38+
},
39+
},
40+
Expect: true,
41+
},
42+
{
43+
Name: "is false when uncompressed user data is true",
44+
Machine: capcv1.CloudStackMachine{
45+
Spec: capcv1.CloudStackMachineSpec{
46+
UncompressedUserData: pointer.Bool(true),
47+
},
48+
},
49+
Expect: false,
50+
},
51+
{
52+
Name: "Is false when uncompressed user data is false",
53+
Machine: capcv1.CloudStackMachine{
54+
Spec: capcv1.CloudStackMachineSpec{
55+
UncompressedUserData: pointer.Bool(false),
56+
},
57+
},
58+
Expect: true,
59+
},
60+
} {
61+
tc := tc
62+
It(tc.Name, func() {
63+
result := tc.Machine.CompressUserdata()
64+
Expect(result).To(Equal(tc.Expect))
65+
})
66+
}
67+
})

docs/book/src/clustercloudstack/configuration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ cmk list zones listall=true | jq '.zone[] | {name, id}'
6161

6262
The network must be declared as an environment variable `CLOUDSTACK_NETWORK_NAME` and is a mandatory parameter.
6363
As of now, only isolated and shared networks are supported.
64-
If the specified network does not exist, a new isolated network will be created.
64+
65+
If the specified network does not exist, a new isolated network will be created. The newly created network will have a default egress firewall policy that allows all TCP, UDP and ICMP traffic from the cluster to the outside world.
6566

6667
The list of networks for the specific zone can be fetched using the cmk cli as follows :
6768
```

docs/book/src/development/common.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,16 @@
6060
clusterctl get kubeconfig capc-cluster > capc-cluster.kubeconfig
6161
```
6262
63-
6. Install calico on the workload cluster so that pods can see each other
63+
6. Install calico or weave net cni plugin on the workload cluster so that pods can see each other
6464
```
65-
KUBECONFIG=capc-cluster.kubeconfig kubectl apply -f https://projectcalico.docs.tigera.io/manifests/calico.yaml
65+
KUBECONFIG=capc-cluster.kubeconfig kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/master/manifests/calico.yaml
66+
67+
```
68+
or
69+
70+
```
71+
KUBECONFIG=capc-cluster.kubeconfig kubectl apply -f https://raw.githubusercontent.com/weaveworks/weave/master/prog/weave-kube/weave-daemonset-k8s-1.11.yaml
72+
6673
```
6774
6875
7. Verify the K8s cluster is fully up. (It may take a minute for the nodes status to all reach *ready* state.)
@@ -87,7 +94,7 @@ KUBECONFIG=capc-cluster.kubeconfig kubectl logs test-thing
8794
```
8895
8996
### kubectl/clusterctl Reference:
90-
- Pods in capc-cluster -- cluster running in Apache CloudStack
97+
- Pods in capc-cluster -- cluster running in Apache CloudStack with calico cni
9198
```
9299
% KUBECONFIG=capc-cluster.kubeconfig kubectl get pods -A
93100
NAMESPACE NAME READY STATUS RESTARTS AGE
@@ -104,6 +111,23 @@ kube-system kube-proxy-6g9zb 1/1
104111
kube-system kube-proxy-7gjbv 1/1 Running 0 9m18s
105112
kube-system kube-scheduler-capc-cluster-control-plane-tknwx 1/1 Running 0 9m21s
106113
```
114+
- Pods in capc-cluster -- cluster running in Apache CloudStack with weave net cni
115+
116+
```
117+
%KUBECONFIG=capc-cluster.kubeconfig kubectl get pods -A
118+
NAMESPACE NAME READY STATUS RESTARTS AGE
119+
default test-thing 0/1 Completed 0 38s
120+
kube-system coredns-5d78c9869d-9xq2s 1/1 Running 0 21h
121+
kube-system coredns-5d78c9869d-gphs2 1/1 Running 0 21h
122+
kube-system etcd-capc-cluster-control-plane-49khm 1/1 Running 0 21h
123+
kube-system kube-apiserver-capc-cluster-control-plane-49khm 1/1 Running 0 21h
124+
kube-system kube-controller-manager-capc-cluster-control-plane-49khm 1/1 Running 0 21h
125+
kube-system kube-proxy-8lfnm 1/1 Running 0 21h
126+
kube-system kube-proxy-brj78 1/1 Running 0 21h
127+
kube-system kube-scheduler-capc-cluster-control-plane-49khm 1/1 Running 0 21h
128+
kube-system weave-net-rqckr 2/2 Running 1 (3h8m ago) 3h8m
129+
kube-system weave-net-rzms4 2/2 Running 1 (3h8m ago) 3h8m
130+
```
107131
108132
- Pods in original kind cluster (also called bootstrap cluster, management cluster)
109133
```
@@ -128,4 +152,4 @@ local-path-storage local-path-provisioner-547f784dff-f2g7r
128152
```
129153
<!--
130154
// ANCHOR_END: common-development
131-
-->
155+
-->

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ require (
2121
k8s.io/client-go v0.25.3
2222
k8s.io/klog/v2 v2.80.1
2323
k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2
24-
sigs.k8s.io/cluster-api v1.2.11
25-
sigs.k8s.io/controller-runtime v0.13.1
24+
sigs.k8s.io/cluster-api v1.2.12
25+
sigs.k8s.io/controller-runtime v0.12.3
2626
)
2727

2828
require (
@@ -102,6 +102,6 @@ require (
102102

103103
replace github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.0.0 // Indirect upgrade to address https://github.com/advisories/GHSA-w73w-5m7g-f7qc
104104

105-
replace sigs.k8s.io/cluster-api/test => sigs.k8s.io/cluster-api/test v1.2.11
105+
replace sigs.k8s.io/cluster-api/test => sigs.k8s.io/cluster-api/test v1.2.12
106106

107-
replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.2.11
107+
replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.2.12

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,10 +1047,10 @@ k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2/go.mod h1:OLgZIPagt7ERELqWJFomSt
10471047
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
10481048
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
10491049
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
1050-
sigs.k8s.io/cluster-api v1.2.11 h1:rtx6fp05qESvtALUGIizUAci0kmiEoVBG786C05L1jU=
1051-
sigs.k8s.io/cluster-api v1.2.11/go.mod h1:VB4qC2t1WjqzBtJvxx3VImb/hLpdXjiWxkdd7OX29mA=
1052-
sigs.k8s.io/controller-runtime v0.13.1 h1:tUsRCSJVM1QQOOeViGeX3GMT3dQF1eePPw6sEE3xSlg=
1053-
sigs.k8s.io/controller-runtime v0.13.1/go.mod h1:Zbz+el8Yg31jubvAEyglRZGdLAjplZl+PgtYNI6WNTI=
1050+
sigs.k8s.io/cluster-api v1.2.12 h1:/1iFgWUR3Z+KZU9B4PJegmlQQo6uzQXBZNgOk63SLu4=
1051+
sigs.k8s.io/cluster-api v1.2.12/go.mod h1:9+fLUuyRsKediKJYrbsyFj6Bmk59oopXpzj3g6/REM8=
1052+
sigs.k8s.io/controller-runtime v0.12.3 h1:FCM8xeY/FI8hoAfh/V4XbbYMY20gElh9yh+A98usMio=
1053+
sigs.k8s.io/controller-runtime v0.12.3/go.mod h1:qKsk4WE6zW2Hfj0G4v10EnNB2jMG1C+NTb8h+DwCoU0=
10541054
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k=
10551055
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
10561056
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE=

hack/ensure-cloud-config-yaml.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2019 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
# This ensures that cloud-config.yaml exists which is required for e2e smoke test
22+
if [ ! -f "cloud-config.yaml" ];then
23+
echo "cloud-config.yaml is not found, creating"
24+
cat >cloud-config.yaml <<EOF
25+
apiVersion: v1
26+
kind: Secret
27+
metadata:
28+
name: secret1
29+
namespace: default
30+
type: Opaque
31+
stringData:
32+
api-key: XXXX
33+
secret-key: XXXX
34+
api-url: http://1.2.3.4:8080/client/api
35+
verify-ssl: "false"
36+
EOF
37+
38+
fi

hack/ensure-kind.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2019 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
GOPATH_BIN="$(go env GOPATH)/bin/"
22+
MINIMUM_KIND_VERSION=v0.14.0
23+
GOARCH="$(go env GOARCH)"
24+
GOOS="$(go env GOOS)"
25+
26+
# Ensure the kind tool exists and is a viable version, or installs it
27+
verify_kind_version() {
28+
29+
# If kind is not available on the path, get it
30+
if ! [ -x "$(command -v kind)" ]; then
31+
if [ "$GOOS" == "linux" ] || [ "$GOOS" == "darwin" ]; then
32+
echo 'kind not found, installing'
33+
if ! [ -d "${GOPATH_BIN}" ]; then
34+
mkdir -p "${GOPATH_BIN}"
35+
fi
36+
curl -sLo "${GOPATH_BIN}/kind" "https://github.com/kubernetes-sigs/kind/releases/download/${MINIMUM_KIND_VERSION}/kind-${GOOS}-${GOARCH}"
37+
chmod +x "${GOPATH_BIN}/kind"
38+
else
39+
echo "Missing required binary in path: kind"
40+
return 2
41+
fi
42+
fi
43+
44+
local kind_version
45+
kind_version="v$(kind version -q)"
46+
if [[ "${MINIMUM_KIND_VERSION}" != $(echo -e "${MINIMUM_KIND_VERSION}\n${kind_version}" | sort -s -t. -k 1,1n -k 2,2n -k 3,3n | head -n1) ]]; then
47+
cat <<EOF
48+
Detected kind version: ${kind_version}.
49+
Requires ${MINIMUM_KIND_VERSION} or greater.
50+
Please install ${MINIMUM_KIND_VERSION} or later.
51+
EOF
52+
return 2
53+
fi
54+
}
55+
56+
verify_kind_version

pkg/cloud/helpers.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package cloud
1818

1919
import (
2020
"bytes"
21-
"compress/gzip"
21+
cgzip "compress/gzip"
2222
)
2323

2424
type set func(string)
@@ -43,13 +43,13 @@ func setIntIfPositive(num int64, setFn setInt) {
4343
}
4444
}
4545

46-
func CompressString(str string) (string, error) {
47-
buf := &bytes.Buffer{}
48-
gzipWriter := gzip.NewWriter(buf)
49-
if _, err := gzipWriter.Write([]byte(str)); err != nil {
46+
func compress(str string) (string, error) {
47+
var buf bytes.Buffer
48+
w := cgzip.NewWriter(&buf)
49+
if _, err := w.Write([]byte(str)); err != nil {
5050
return "", err
5151
}
52-
if err := gzipWriter.Close(); err != nil {
52+
if err := w.Close(); err != nil {
5353
return "", err
5454
}
5555
return buf.String(), nil

0 commit comments

Comments
 (0)