update some steps
Signed-off-by: James Strong <strong.james.e@gmail.com>
This commit is contained in:
parent
d8bb8596dc
commit
e737b68537
1 changed files with 23 additions and 32 deletions
|
@ -22,6 +22,7 @@ import (
|
||||||
|
|
||||||
"github.com/magefile/mage/mg"
|
"github.com/magefile/mage/mg"
|
||||||
"github.com/magefile/mage/sh"
|
"github.com/magefile/mage/sh"
|
||||||
|
"k8s.io/ingress-nginx/magefiles/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Kind mg.Namespace
|
type Kind mg.Namespace
|
||||||
|
@ -32,9 +33,11 @@ var K8_VERSION string = "kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297
|
||||||
var KIND_LOG_LEVEL string = "6"
|
var KIND_LOG_LEVEL string = "6"
|
||||||
var GATEWAY_API_VERSION string = "v1.0.0"
|
var GATEWAY_API_VERSION string = "v1.0.0"
|
||||||
var CRD_CHANNEL string = "standard"
|
var CRD_CHANNEL string = "standard"
|
||||||
var GWAPI_CRD_BASE_URL string = "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api"
|
var GWAPI_CRD_BASE_URL string = "https://github.com/kubernetes-sigs/gateway-api/releases/download"
|
||||||
|
|
||||||
// Creates a new cluster mage kind:createcluster name k8sversion
|
var k = sh.RunCmd("kubectl", "apply", "-f")
|
||||||
|
|
||||||
|
// Creates a new cluster mage kind:createcluster cluster-name k8sversion
|
||||||
func (Kind) CreateCluster(clusterName, k8sVersion string) error {
|
func (Kind) CreateCluster(clusterName, k8sVersion string) error {
|
||||||
|
|
||||||
if len(clusterName) > 0 {
|
if len(clusterName) > 0 {
|
||||||
|
@ -45,15 +48,17 @@ func (Kind) CreateCluster(clusterName, k8sVersion string) error {
|
||||||
K8_VERSION = fmt.Sprintf("kindest/node:%s", k8sVersion)
|
K8_VERSION = fmt.Sprintf("kindest/node:%s", k8sVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get the list of kind clusters install
|
||||||
cluster, err := sh.Output("kind", "get", "clusters")
|
cluster, err := sh.Output("kind", "get", "clusters")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//delete the cluster if it exists
|
||||||
if strings.Contains(cluster, KIND_CLUSTER_NAME) {
|
if strings.Contains(cluster, KIND_CLUSTER_NAME) {
|
||||||
|
utils.Info("%s exists deleting and recreating", KIND_CLUSTER_NAME)
|
||||||
err := sh.Run("kind", "delete", "cluster", "--name", KIND_CLUSTER_NAME)
|
err := sh.Run("kind", "delete", "cluster", "--name", KIND_CLUSTER_NAME)
|
||||||
if err != nil {
|
utils.CheckIfError(err, "deleting kind cluster %s", KIND_CLUSTER_NAME)
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = sh.RunV("kind", "create", "cluster",
|
err = sh.RunV("kind", "create", "cluster",
|
||||||
|
@ -69,28 +74,17 @@ func (Kind) CreateCluster(clusterName, k8sVersion string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// InstallGatewayCRD Install Gateway API CRDS for testing
|
// InstallGatewayCRD Install Gateway API CRDS for testing mage kind:installgatewaycrd
|
||||||
func (Kind) InstallGatewayCRD() error {
|
func (Kind) InstallGatewayCRD() error {
|
||||||
var k = sh.RunCmd("kubectl", "apply", "-f")
|
|
||||||
|
|
||||||
gatewayClass := fmt.Sprintf("%s/%s/config/crd/%s/gateway.networking.k8s.io_gatewayclasses.yaml", GWAPI_CRD_BASE_URL, GATEWAY_API_VERSION, CRD_CHANNEL)
|
gateway := fmt.Sprintf("%s/%s/standard-install.yaml", GWAPI_CRD_BASE_URL, GATEWAY_API_VERSION)
|
||||||
gateway := fmt.Sprintf("%s/%s/config/crd/%s/gateway.networking.k8s.io_gateways.yaml", GWAPI_CRD_BASE_URL, GATEWAY_API_VERSION, CRD_CHANNEL)
|
|
||||||
httpRoutes := fmt.Sprintf("%s/%s/config/crd/%s/gateway.networking.k8s.io_httproutes.yaml", GWAPI_CRD_BASE_URL, GATEWAY_API_VERSION, CRD_CHANNEL)
|
|
||||||
|
|
||||||
if err := k(gatewayClass); err != nil {
|
err := k(gateway)
|
||||||
return err
|
utils.CheckIfError(err, "install gateway crd %s", gateway)
|
||||||
}
|
|
||||||
if err := k(gateway); err != nil {
|
err = sh.RunV("kubectl", "get", "crds")
|
||||||
return err
|
utils.CheckIfError(err, "verifying gateway crd %s", gateway)
|
||||||
}
|
|
||||||
if err := k(httpRoutes); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err := sh.RunV("kubectl", "get", "crds")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,23 +92,20 @@ func getWorkers() (string, error) {
|
||||||
return sh.Output("kind", "get", "nodes", fmt.Sprintf("--name=%s", KIND_CLUSTER_NAME))
|
return sh.Output("kind", "get", "nodes", fmt.Sprintf("--name=%s", KIND_CLUSTER_NAME))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InstallMetalLB install metallb in the current context cluster mage kind:installmetallb
|
||||||
func (Kind) InstallMetalLB() error {
|
func (Kind) InstallMetalLB() error {
|
||||||
|
|
||||||
err := sh.RunV("kubectl", "apply", "-f", "https://raw.githubusercontent.com/metallb/metallb/v0.14.4/config/manifests/metallb-native.yaml")
|
err := sh.RunV("kubectl", "apply", "-f", "https://raw.githubusercontent.com/metallb/metallb/v0.14.4/config/manifests/metallb-native.yaml")
|
||||||
if err != nil {
|
utils.CheckIfError(err, "install metallb")
|
||||||
return err
|
|
||||||
}
|
|
||||||
err = sh.RunV("kubectl", "wait", "--namespace", "metallb-system",
|
err = sh.RunV("kubectl", "wait", "--namespace", "metallb-system",
|
||||||
"--for=condition=ready", "pod",
|
"--for=condition=ready", "pod",
|
||||||
"--selector=app=metallb",
|
"--selector=app=metallb",
|
||||||
"--timeout=90s")
|
"--timeout=90s")
|
||||||
if err != nil {
|
utils.CheckIfError(err, "waiting on metallb install")
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = sh.RunV("kubectl", "apply", "-f", "test/metallb-config.yaml")
|
err = sh.RunV("kubectl", "apply", "-f", "test/metallb-config.yaml")
|
||||||
if err != nil {
|
utils.CheckIfError(err, "install test metallb configuration, check test/metallb-config.yaml")
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue