Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
Update node for kind cluster on CI
Browse files Browse the repository at this point in the history
This commit increase the node count for kind cluster used in the CI.

Signed-off-by: Sneha Chhabria <snchh@microsoft.com>
  • Loading branch information
snehachhabria committed Jul 21, 2021
1 parent 94394bd commit b8ed86b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/nightly-noinstall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
kubeadmConfigPatches:
- |
kind: InitConfiguration
Expand All @@ -32,6 +33,7 @@ jobs:
- containerPort: 80
hostPort: 80
protocol: TCP
- role: worker
EOF
cat kind-config.yaml
Expand Down
4 changes: 4 additions & 0 deletions scripts/kind-with-registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ echo "Registry Host: ${reg_host}"
cat <<EOF | kind create cluster --name "${KIND_CLUSTER_NAME}" --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"]
Expand Down
39 changes: 37 additions & 2 deletions tests/framework/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"flag"
"fmt"
"io"
"io/ioutil"
"math"
"math/big"
Expand Down Expand Up @@ -92,6 +93,9 @@ const (
// DefaultUpstreamServicePort is the default port on which the server apps listen for connections from client apps.
// Note: Port 80 should not be used because it does not work on OpenShift.
DefaultUpstreamServicePort = 14001

// nodeCount defines the number of nodes for the kind cluster
nodeCount = 3
)

// HttpbinCmd is the command to be used for httpbin applications in e2es
Expand Down Expand Up @@ -222,6 +226,23 @@ func (td *OsmTestData) InitTestData(t GinkgoTInterface) error {
Nodes: []v1alpha4.Node{
{
Role: v1alpha4.ControlPlaneRole,
},
{
Role: v1alpha4.WorkerRole,
KubeadmConfigPatches: []string{`kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"`},
ExtraPortMappings: []v1alpha4.PortMapping{
{
ContainerPort: 80,
HostPort: 80,
Protocol: v1alpha4.PortMappingProtocolTCP,
},
},
},
{
Role: v1alpha4.WorkerRole,
KubeadmConfigPatches: []string{`kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
Expand All @@ -237,7 +258,10 @@ nodeRegistration:
},
}
if Td.ClusterVersion != "" {
clusterConfig.Nodes[0].Image = fmt.Sprintf("kindest/node:%s", td.ClusterVersion)
for i := 0; i < nodeCount; i++ {
clusterConfig.Nodes[i].Image = fmt.Sprintf("kindest/node:%s", td.ClusterVersion)
}

}
if err := td.ClusterProvider.Create(td.ClusterName, cluster.CreateWithV1Alpha4Config(clusterConfig)); err != nil {
return errors.Wrap(err, "failed to create kind cluster")
Expand Down Expand Up @@ -346,14 +370,25 @@ func (td *OsmTestData) LoadImagesToKind(imageNames []string) error {
if err != nil {
return errors.Wrap(err, "failed to get image data")
}

imageReader, err := ioutil.ReadAll(imageData)
if err != nil {
return errors.Wrap(err, "failed to read images")
}

reader := bytes.NewReader(imageReader)
defer imageData.Close() //nolint: errcheck,gosec
nodes, err := td.ClusterProvider.ListNodes(td.ClusterName)
if err != nil {
return errors.Wrap(err, "failed to list kind nodes")
}

for _, n := range nodes {
td.T.Log("Loading images onto node", n)
if err := nodeutils.LoadImageArchive(n, imageData); err != nil {
if _, err := reader.Seek(0, io.SeekStart); err != nil {
return errors.Wrap(err, "failed to reset images")
}
if err = nodeutils.LoadImageArchive(n, reader); err != nil {
return errors.Wrap(err, "failed to load images")
}
}
Expand Down

0 comments on commit b8ed86b

Please sign in to comment.