Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump istioctl #1331

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 49 additions & 53 deletions cluster-provision/gocli/opts/istio/istio.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (

"github.com/cenkalti/backoff/v4"
"github.com/sirupsen/logrus"
istiov1alpha1 "istio.io/operator/pkg/apis/istio/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
k8s "kubevirt.io/kubevirtci/cluster-provision/gocli/pkg/k8s"
Expand All @@ -23,7 +24,7 @@ var istioWithCnao []byte
//go:embed manifests/istio-operator.cr.yaml
var istioNoCnao []byte

const istioVersion = "1.15.0"
const istioVersion = "1.24.1"

type istioOpt struct {
cnaoEnabled bool
Expand All @@ -49,70 +50,65 @@ func (o *istioOpt) Exec() error {
return err
}

istioFile := "/opt/istio-operator-with-cnao.yaml"
if !o.cnaoEnabled {
istioFile = "/opt/istio-operator.cr.yaml"
}

cmds := []string{
"source /var/lib/kubevirtci/shared_vars.sh",
"PATH=/opt/istio-" + istioVersion + "/bin:$PATH istioctl --kubeconfig /etc/kubernetes/admin.conf --hub quay.io/kubevirtci operator init",
`echo '` + string(istioWithCnao) + `' | tee /opt/istio-operator-with-cnao.yaml > /dev/null`,
`echo '` + string(istioNoCnao) + `' | tee /opt/istio-operator.cr.yaml > /dev/null`,
}
for _, cmd := range cmds {
if err := o.sshClient.Command(cmd); err != nil {
return err
}
}

obj, err = k8s.SerializeIntoObject(istioWithCnao)
if err != nil {
return err
}

if o.cnaoEnabled {
if err := o.client.Apply(obj); err != nil {
return err
}
} else {
obj, err = k8s.SerializeIntoObject(istioNoCnao)
if err != nil {
return err
}

if err := o.client.Apply(obj); err != nil {
return err
go func() {
operation := func() error {
obj, err := o.client.Get(schema.GroupVersionKind{Group: "apps",
Version: "v1",
Kind: "DaemonSet"}, "istio-cni-node", "kube-system")
if err != nil {
fmt.Printf("Error getting the CNI DaemonSet: %s\n", err.Error())
return err
}

cniDaemonSet := &appsv1.DaemonSet{}
err = runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, cniDaemonSet)
if err != nil {
fmt.Printf("Error converting the CNI DaemonSet: %s\n", err.Error())
return err
}

privileged := true
cniDaemonSet.Spec.Template.Spec.Containers[0].SecurityContext.Privileged = &privileged
newCniDaemonSet, err := runtime.DefaultUnstructuredConverter.ToUnstructured(cniDaemonSet)
if err != nil {
fmt.Printf("Error converting the CNI DaemonSet: %s\n", err.Error())
return err
}

err = o.client.Update(&unstructured.Unstructured{Object: newCniDaemonSet})
if err != nil {
fmt.Printf("Error patching the CNI DaemonSet: %s\n", err.Error())
return err
}
return nil
}
}

operator := &istiov1alpha1.IstioOperator{}
backoffStrategy := backoff.NewExponentialBackOff()
backoffStrategy.InitialInterval = 10 * time.Second
backoffStrategy.MaxElapsedTime = 3 * time.Minute

operation := func() error {
obj, err := o.client.Get(schema.GroupVersionKind{Group: "install.istio.io",
Version: "v1alpha1",
Kind: "IstioOperator"}, "istio-operator", "istio-system")
_ = backoff.Retry(operation, backoffStrategy)
}()

err = runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, operator)
if err != nil {
return err
}

if operator.Status == nil {
err := fmt.Errorf("Operator status is still not ready")
logrus.Info("Istio operator is still not ready, Backing off and retrying")
return err
}

if operator.Status.Status != 3 {
err := fmt.Errorf("Istio operator failed to move to Healthy status after max retries")
logrus.Info("Istio operator is still not ready, Backing off and retrying")
return err
}

return nil
}

backoffStrategy := backoff.NewExponentialBackOff()
backoffStrategy.InitialInterval = 10 * time.Second
backoffStrategy.MaxElapsedTime = 3 * time.Minute

err = backoff.Retry(operation, backoffStrategy)
if err != nil {
return fmt.Errorf("Waiting on istio operator to become ready failed after maximum retries: %v", err)
istioInstallCmd := "PATH=/opt/istio-" + istioVersion + "/bin:$PATH istioctl --kubeconfig /etc/kubernetes/admin.conf install -y -f " + istioFile
if err := o.sshClient.Command(istioInstallCmd); err != nil {
return err
}

logrus.Info("Istio operator is now ready!")
Expand Down
3 changes: 1 addition & 2 deletions cluster-provision/gocli/opts/istio/istio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ var _ = Describe("IstioOpt", func() {
BeforeEach(func() {
mockCtrl = gomock.NewController(GinkgoT())
sshClient = kubevirtcimocks.NewMockSSHClient(mockCtrl)
r := k8s.NewReactorConfig("create", "istiooperators", IstioReactor)
k8sclient = k8s.NewTestClient(r)
k8sclient = k8s.NewTestClient()
opt = NewIstioOpt(sshClient, k8sclient, false)
AddExpectCalls(sshClient)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
name: istio-operator
spec:
profile: demo
hub: quay.io/kubevirtci
components:
cni:
enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
name: istio-operator
spec:
profile: demo
hub: quay.io/kubevirtci
components:
cni:
enabled: true
Expand Down
4 changes: 3 additions & 1 deletion cluster-provision/gocli/opts/istio/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ var IstioReactor = func(action k8stesting.Action) (bool, runtime.Object, error)
func AddExpectCalls(sshClient *kubevirtcimocks.MockSSHClient) {
cmds := []string{
"source /var/lib/kubevirtci/shared_vars.sh",
"PATH=/opt/istio-1.15.0/bin:$PATH istioctl --kubeconfig /etc/kubernetes/admin.conf --hub quay.io/kubevirtci operator init",
`echo '` + string(istioWithCnao) + `' | tee /opt/istio-operator-with-cnao.yaml > /dev/null`,
`echo '` + string(istioNoCnao) + `' | tee /opt/istio-operator.cr.yaml > /dev/null`,
"PATH=/opt/istio-" + istioVersion + "/bin:$PATH istioctl --kubeconfig /etc/kubernetes/admin.conf install -y -f /opt/istio-operator.cr.yaml",
}

for _, cmd := range cmds {
Expand Down
27 changes: 27 additions & 0 deletions cluster-provision/gocli/pkg/k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package utils
import (
"context"
"fmt"
"strings"
"time"

monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
Expand All @@ -16,6 +17,7 @@ import (
cdiv1beta1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"

"github.com/cenkalti/backoff/v4"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -39,6 +41,7 @@ type K8sDynamicClient interface {
Apply(obj *unstructured.Unstructured) error
List(gvk schema.GroupVersionKind, ns string) (*unstructured.UnstructuredList, error)
Delete(gvk schema.GroupVersionKind, name, ns string) error
Update(newResource *unstructured.Unstructured) error
}

type k8sDynamicClientImpl struct {
Expand Down Expand Up @@ -103,9 +106,32 @@ func (c *k8sDynamicClientImpl) Get(gvk schema.GroupVersionKind, name, ns string)
if err != nil {
return nil, err
}

return obj, nil
}

func (c *k8sDynamicClientImpl) Update(newResource *unstructured.Unstructured) error {
gv := strings.Split(newResource.GetAPIVersion(), "/")
if len(gv) != 2 {
return fmt.Errorf("Resource has no proper group and version. Got: %s\n", newResource.GetAPIVersion())
}

resourceClient, err := c.initResourceClientForGVKAndNamespace(schema.GroupVersionKind{
Group: gv[0],
Version: gv[1],
Kind: newResource.GetKind(),
}, newResource.GetNamespace())
if err != nil {
return err
}

_, err = resourceClient.Update(context.TODO(), newResource, v1.UpdateOptions{})
if err != nil {
return err
}
return nil
}

func (c *k8sDynamicClientImpl) List(gvk schema.GroupVersionKind, ns string) (*unstructured.UnstructuredList, error) {
resourceClient, err := c.initResourceClientForGVKAndNamespace(gvk, ns)
if err != nil {
Expand Down Expand Up @@ -192,6 +218,7 @@ func initSchema() *runtime.Scheme {
_ = cdiv1beta1.AddToScheme(s)
_ = aaqv1alpha1.AddToScheme(s)
_ = corev1.AddToScheme(s)
_ = appsv1.AddToScheme(s)
return s
}

Expand Down
6 changes: 3 additions & 3 deletions cluster-provision/k8s/1.29/extra-pre-pull-images
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
quay.io/kubevirtci/install-cni:1.15.0
quay.io/kubevirtci/operator:1.15.0
quay.io/kubevirtci/pilot:1.15.0
quay.io/kubevirtci/proxyv2:1.15.0
quay.io/calico/cni:v3.26.5
quay.io/calico/kube-controllers:v3.26.5
Expand All @@ -14,6 +11,9 @@ quay.io/kubevirt/cdi-apiserver:v1.58.1
quay.io/kubevirt/cdi-controller:v1.58.1
quay.io/kubevirt/cdi-operator:v1.58.1
quay.io/kubevirt/cdi-uploadproxy:v1.58.1
docker.io/istio/install-cni:1.24.1
docker.io/istio/pilot:1.24.1
docker.io/istio/proxyv2:1.24.1
Copy link
Member

@brianmcarey brianmcarey Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to get these images copied over to our quay account so that we don't hit any docker io limits

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The older images at the top of the file can be removed

quay.io/kubevirtci/install-cni:1.15.0
quay.io/kubevirtci/operator:1.15.0
quay.io/kubevirtci/pilot:1.15.0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asking to understand: @brianmcarey from what I know we have container image cache on CI, is it correct?
Is so, do we still need mirroring if we have cache?

quay.io/kubevirt/cluster-network-addons-operator:v0.87.0
quay.io/kubevirt/cni-default-plugins@sha256:825e3f9fec1996c54a52cec806154945b38f76476b160d554c36e38dfffe5e61
quay.io/kubevirt/kubemacpool@sha256:afba7d0c4a95d2d4924f6ee6ef16bbe59117877383819057f01809150829cb0c
Expand Down
5 changes: 3 additions & 2 deletions cluster-provision/k8s/1.29/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fi

KUBEVIRTCI_SHARED_DIR=/var/lib/kubevirtci
mkdir -p $KUBEVIRTCI_SHARED_DIR
export ISTIO_VERSION=1.15.0
export ISTIO_VERSION=1.24.1
cat << EOF > $KUBEVIRTCI_SHARED_DIR/shared_vars.sh
#!/bin/bash
set -ex
Expand Down Expand Up @@ -57,7 +57,8 @@ export PATH="$ISTIO_BIN_DIR:$PATH"
(
set -E
mkdir -p "$ISTIO_BIN_DIR"
curl "https://storage.googleapis.com/kubevirtci-istioctl-mirror/istio-${ISTIO_VERSION}/bin/istioctl" -o "$ISTIO_BIN_DIR/istioctl"
curl -L https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/istio-${ISTIO_VERSION}-linux-amd64.tar.gz -O
tar -xvf ./istio-${ISTIO_VERSION}-linux-amd64.tar.gz --strip-components=2 -C ${ISTIO_BIN_DIR} istio-${ISTIO_VERSION}/bin/istioctl
chmod +x "$ISTIO_BIN_DIR/istioctl"
)

Expand Down
6 changes: 3 additions & 3 deletions cluster-provision/k8s/1.30/extra-pre-pull-images
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
quay.io/kubevirtci/install-cni:1.15.0
quay.io/kubevirtci/operator:1.15.0
quay.io/kubevirtci/pilot:1.15.0
quay.io/kubevirtci/proxyv2:1.15.0
quay.io/calico/cni:v3.26.5
quay.io/calico/kube-controllers:v3.26.5
Expand All @@ -14,6 +11,9 @@ quay.io/kubevirt/cdi-apiserver:v1.58.1
quay.io/kubevirt/cdi-controller:v1.58.1
quay.io/kubevirt/cdi-operator:v1.58.1
quay.io/kubevirt/cdi-uploadproxy:v1.58.1
docker.io/istio/install-cni:1.24.1
docker.io/istio/pilot:1.24.1
docker.io/istio/proxyv2:1.24.1
quay.io/kubevirt/cluster-network-addons-operator:v0.87.0
quay.io/kubevirt/cni-default-plugins@sha256:825e3f9fec1996c54a52cec806154945b38f76476b160d554c36e38dfffe5e61
quay.io/kubevirt/kubemacpool@sha256:afba7d0c4a95d2d4924f6ee6ef16bbe59117877383819057f01809150829cb0c
Expand Down
5 changes: 3 additions & 2 deletions cluster-provision/k8s/1.30/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARCH=$(uname -m)

KUBEVIRTCI_SHARED_DIR=/var/lib/kubevirtci
mkdir -p $KUBEVIRTCI_SHARED_DIR
export ISTIO_VERSION=1.15.0
export ISTIO_VERSION=1.24.1
cat << EOF > $KUBEVIRTCI_SHARED_DIR/shared_vars.sh
#!/bin/bash
set -ex
Expand Down Expand Up @@ -52,7 +52,8 @@ export PATH="$ISTIO_BIN_DIR:$PATH"
(
set -E
mkdir -p "$ISTIO_BIN_DIR"
curl "https://storage.googleapis.com/kubevirtci-istioctl-mirror/istio-${ISTIO_VERSION}/bin/istioctl" -o "$ISTIO_BIN_DIR/istioctl"
curl -L https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/istio-${ISTIO_VERSION}-linux-amd64.tar.gz -O
tar -xvf ./istio-${ISTIO_VERSION}-linux-amd64.tar.gz --strip-components=2 -C ${ISTIO_BIN_DIR} istio-${ISTIO_VERSION}/bin/istioctl
chmod +x "$ISTIO_BIN_DIR/istioctl"
)

Expand Down
3 changes: 3 additions & 0 deletions cluster-provision/k8s/1.31/extra-pre-pull-images
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ quay.io/kubevirt/cdi-apiserver:v1.58.1
quay.io/kubevirt/cdi-controller:v1.58.1
quay.io/kubevirt/cdi-operator:v1.58.1
quay.io/kubevirt/cdi-uploadproxy:v1.58.1
docker.io/istio/install-cni:1.24.1
docker.io/istio/pilot:1.24.1
docker.io/istio/proxyv2:1.24.1
quay.io/kubevirt/cluster-network-addons-operator:v0.87.0
quay.io/kubevirt/cni-default-plugins@sha256:825e3f9fec1996c54a52cec806154945b38f76476b160d554c36e38dfffe5e61
quay.io/kubevirt/kubemacpool@sha256:afba7d0c4a95d2d4924f6ee6ef16bbe59117877383819057f01809150829cb0c
Expand Down
5 changes: 3 additions & 2 deletions cluster-provision/k8s/1.31/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARCH=$(uname -m)

KUBEVIRTCI_SHARED_DIR=/var/lib/kubevirtci
mkdir -p $KUBEVIRTCI_SHARED_DIR
export ISTIO_VERSION=1.15.0
export ISTIO_VERSION=1.24.1
cat << EOF > $KUBEVIRTCI_SHARED_DIR/shared_vars.sh
#!/bin/bash
set -ex
Expand Down Expand Up @@ -52,7 +52,8 @@ export PATH="$ISTIO_BIN_DIR:$PATH"
(
set -E
mkdir -p "$ISTIO_BIN_DIR"
curl "https://storage.googleapis.com/kubevirtci-istioctl-mirror/istio-${ISTIO_VERSION}/bin/istioctl" -o "$ISTIO_BIN_DIR/istioctl"
curl -L https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/istio-${ISTIO_VERSION}-linux-amd64.tar.gz -O
tar -xvf ./istio-${ISTIO_VERSION}-linux-amd64.tar.gz --strip-components=2 -C ${ISTIO_BIN_DIR} istio-${ISTIO_VERSION}/bin/istioctl
chmod +x "$ISTIO_BIN_DIR/istioctl"
)

Expand Down
6 changes: 3 additions & 3 deletions cluster-provision/k8s/1.32/extra-pre-pull-images
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
quay.io/kubevirtci/install-cni:1.15.0
quay.io/kubevirtci/operator:1.15.0
quay.io/kubevirtci/pilot:1.15.0
quay.io/kubevirtci/proxyv2:1.15.0
quay.io/calico/cni:v3.26.5
quay.io/calico/kube-controllers:v3.26.5
Expand All @@ -14,6 +11,9 @@ quay.io/kubevirt/cdi-apiserver:v1.58.1
quay.io/kubevirt/cdi-controller:v1.58.1
quay.io/kubevirt/cdi-operator:v1.58.1
quay.io/kubevirt/cdi-uploadproxy:v1.58.1
docker.io/istio/install-cni:1.24.1
docker.io/istio/pilot:1.24.1
docker.io/istio/proxyv2:1.24.1
quay.io/kubevirt/cluster-network-addons-operator:v0.87.0
quay.io/kubevirt/cni-default-plugins@sha256:825e3f9fec1996c54a52cec806154945b38f76476b160d554c36e38dfffe5e61
quay.io/kubevirt/kubemacpool@sha256:afba7d0c4a95d2d4924f6ee6ef16bbe59117877383819057f01809150829cb0c
Expand Down
5 changes: 3 additions & 2 deletions cluster-provision/k8s/1.32/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARCH=$(uname -m)

KUBEVIRTCI_SHARED_DIR=/var/lib/kubevirtci
mkdir -p $KUBEVIRTCI_SHARED_DIR
export ISTIO_VERSION=1.15.0
export ISTIO_VERSION=1.24.1
cat << EOF > $KUBEVIRTCI_SHARED_DIR/shared_vars.sh
#!/bin/bash
set -ex
Expand Down Expand Up @@ -52,7 +52,8 @@ export PATH="$ISTIO_BIN_DIR:$PATH"
(
set -E
mkdir -p "$ISTIO_BIN_DIR"
curl "https://storage.googleapis.com/kubevirtci-istioctl-mirror/istio-${ISTIO_VERSION}/bin/istioctl" -o "$ISTIO_BIN_DIR/istioctl"
curl -L https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/istio-${ISTIO_VERSION}-linux-amd64.tar.gz -O
tar -xvf ./istio-${ISTIO_VERSION}-linux-amd64.tar.gz --strip-components=2 -C ${ISTIO_BIN_DIR} istio-${ISTIO_VERSION}/bin/istioctl
chmod +x "$ISTIO_BIN_DIR/istioctl"
)

Expand Down
2 changes: 1 addition & 1 deletion cluster-provision/k8s/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
set -ex

PHASES_DEFAULT="linux,k8s"
PHASES="${PHASES:-$PHASES_DEFAULT}"
PHASES="$PHASES_DEFAULT"
aerosouund marked this conversation as resolved.
Show resolved Hide resolved
CHECK_CLUSTER="${CHECK_CLUSTER:-false}"
export SLIM="${SLIM:-false}"
BYPASS_PMAN_CHANGE_CHECK=${BYPASS_PMAN_CHANGE_CHECK:-false}
Expand Down