Skip to content

Commit

Permalink
Make Istio tests deploy Istio in strict mode (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
thegridman committed Sep 25, 2023
1 parent 98f08f0 commit 16383c8
Show file tree
Hide file tree
Showing 19 changed files with 274 additions and 101 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yaml
Expand Up @@ -63,15 +63,15 @@ jobs:
df -h
- name: Set up JDK
uses: actions/setup-java@v3
uses: oracle-actions/setup-java@v1
with:
distribution: 'zulu'
java-version: '11'
website: oracle.com
release: 21

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Cache Go Modules
uses: actions/cache@v3
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/coherence-matrix.yaml
Expand Up @@ -70,8 +70,8 @@ jobs:
baseImage: "gcr.io/distroless/java17-debian11"

- matrixName: "22.06"
coherenceVersion: "22.06.4"
coherenceImage: "ghcr.io/oracle/coherence-ce:22.06.4"
coherenceVersion: "22.06.5"
coherenceImage: "ghcr.io/oracle/coherence-ce:22.06.5"
javaVersion: 11
baseImage: "gcr.io/distroless/java11-debian11"

Expand Down Expand Up @@ -139,15 +139,15 @@ jobs:
df -h
- name: Set up JDK
uses: actions/setup-java@v3
uses: oracle-actions/setup-java@v1
with:
distribution: 'zulu'
java-version: '17'
website: oracle.com
release: 21

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Cache Go Modules
uses: actions/cache@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/compatibility-tests.yaml
Expand Up @@ -97,15 +97,15 @@ jobs:
df -h
- name: Set up JDK
uses: actions/setup-java@v3
uses: oracle-actions/setup-java@v1
with:
distribution: 'zulu'
java-version: '11'
website: oracle.com
release: 21

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Cache Go Modules
uses: actions/cache@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/doc-check.yaml
Expand Up @@ -31,15 +31,15 @@ jobs:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v3
uses: oracle-actions/setup-java@v1
with:
distribution: 'zulu'
java-version: '11'
website: oracle.com
release: 21

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Cache Go Modules
uses: actions/cache@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/istio-tests.yaml
Expand Up @@ -69,15 +69,15 @@ jobs:
df -h
- name: Set up JDK
uses: actions/setup-java@v3
uses: oracle-actions/setup-java@v1
with:
distribution: 'zulu'
java-version: '11'
website: oracle.com
release: 21

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Cache Go Modules
uses: actions/cache@v3
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/k8s-matrix.yaml
Expand Up @@ -49,19 +49,19 @@ jobs:
- v1.21
include:
- matrixName: v1.27
k8s: kindest/node:v1.27.1@sha256:9915f5629ef4d29f35b478e819249e89cfaffcbfeebda4324e5c01d53d937b09
k8s: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
kindCommand: kind-calico
runNetTests: true
- matrixName: v1.26
k8s: kindest/node:v1.26.3@sha256:61b92f38dff6ccc29969e7aa154d34e38b89443af1a2c14e6cfbd2df6419c66f
k8s: kindest/node:v1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb
kindCommand: kind-calico
runNetTests: true
- matrixName: v1.25
k8s: kindest/node:v1.25.8@sha256:00d3f5314cc35327706776e95b2f8e504198ce59ac545d0200a89e69fce10b7f
k8s: kindest/node:v1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8
kindCommand: kind-calico
runNetTests: true
- matrixName: v1.24
k8s: kindest/node:v1.24.12@sha256:1e12918b8bc3d4253bc08f640a231bb0d3b2c5a9b28aa3f2ca1aee93e1e8db16
k8s: kindest/node:v1.24.15@sha256:7db4f8bea3e14b82d12e044e25e34bd53754b7f2b0e9d56df21774e6f66a70ab
kindCommand: kind-calico
runNetTests: true
- matrixName: v1.23
Expand Down Expand Up @@ -105,15 +105,15 @@ jobs:
df -h
- name: Set up JDK
uses: actions/setup-java@v3
uses: oracle-actions/setup-java@v1
with:
distribution: 'zulu'
java-version: '11'
website: oracle.com
release: 21

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Cache Go Modules
uses: actions/cache@v3
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/minikube-matrix.yaml
Expand Up @@ -40,19 +40,19 @@ jobs:
fail-fast: false
matrix:
matrixName:
- v1.28
- v1.27
- v1.26
- v1.25
- v1.24
include:
- matrixName: v1.28
k8s: v1.28.2
- matrixName: v1.27
k8s: v1.27.1
k8s: v1.27.6
- matrixName: v1.26
k8s: v1.26.3
k8s: v1.26.9
- matrixName: v1.25
k8s: 1.25.8
- matrixName: v1.24
k8s: 1.24.12
k8s: 1.25.14

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -82,15 +82,15 @@ jobs:
df -h
- name: Set up JDK
uses: actions/setup-java@v3
uses: oracle-actions/setup-java@v1
with:
distribution: 'zulu'
java-version: '11'
website: oracle.com
release: 21

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Cache Go Modules
uses: actions/cache@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/prometheus-tests.yaml
Expand Up @@ -63,15 +63,15 @@ jobs:
df -h
- name: Set up JDK
uses: actions/setup-java@v3
uses: oracle-actions/setup-java@v1
with:
distribution: 'zulu'
java-version: '11'
website: oracle.com
release: 21

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Cache Go Modules
uses: actions/cache@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Expand Up @@ -24,15 +24,15 @@ jobs:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v3
uses: oracle-actions/setup-java@v1
with:
distribution: 'zulu'
java-version: '11'
website: oracle.com
release: 21

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Cache Go Modules
uses: actions/cache@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tanzu-tests.yaml
Expand Up @@ -67,15 +67,15 @@ jobs:
df -h
- name: Set up JDK
uses: actions/setup-java@v3
uses: oracle-actions/setup-java@v1
with:
distribution: 'zulu'
java-version: '11'
website: oracle.com
release: 21

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Cache Go Modules
uses: actions/cache@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/trivy.yaml
Expand Up @@ -53,15 +53,15 @@ jobs:
df -h
- name: Set up JDK
uses: actions/setup-java@v3
uses: oracle-actions/setup-java@v1
with:
distribution: 'zulu'
java-version: '11'
website: oracle.com
release: 21

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x

- name: Cache Go Modules
uses: actions/cache@v3
Expand Down
19 changes: 9 additions & 10 deletions Makefile
Expand Up @@ -332,7 +332,7 @@ TEST_SSL_SECRET := coherence-ssl-secret
# ----------------------------------------------------------------------------------------------------------------------
# Prometheus Operator settings (used in integration tests)
# ----------------------------------------------------------------------------------------------------------------------
PROMETHEUS_VERSION ?= v0.10.0
PROMETHEUS_VERSION ?= v0.13.0
PROMETHEUS_HOME = $(TOOLS_DIRECTORY)/prometheus/$(PROMETHEUS_VERSION)
PROMETHEUS_NAMESPACE ?= monitoring
PROMETHEUS_ADAPTER_VERSION ?= 2.5.0
Expand Down Expand Up @@ -1558,8 +1558,7 @@ create-ssl-secrets: $(BUILD_OUTPUT)/certs
##@ KinD

KIND_CLUSTER ?= operator
KIND_IMAGE ?= "kindest/node:v1.24.7@sha256:577c630ce8e509131eab1aea12c022190978dd2f745aac5eb1fe65c0807eb315"
#KIND_IMAGE ?= "kindest/node:v1.25.3@sha256:f52781bc0d7a19fb6c405c2af83abfeb311f130707a0e219175677e366cc45d1"
KIND_IMAGE ?= "kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72"
CALICO_TIMEOUT ?= 300s

# ----------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2102,20 +2101,20 @@ uninstall-metallb: ## Uninstall MetalLB
install-istio: get-istio ## Install the latest version of Istio into k8s (or override the version using the ISTIO_VERSION env var)
$(eval ISTIO_HOME := $(shell find $(TOOLS_DIRECTORY) -maxdepth 1 -type d | grep istio))
$(ISTIO_HOME)/bin/istioctl install --set profile=demo -y
sleep 10
kubectl -n istio-system get pod -l app=istio-egressgateway -o name | xargs \
kubectl -n istio-system wait --for condition=ready --timeout 300s
kubectl -n istio-system get pod -l app=istio-ingressgateway -o name | xargs \
kubectl -n istio-system wait --for condition=ready --timeout 300s
kubectl -n istio-system get pod -l app=istiod -o name | xargs \
kubectl -n istio-system wait --for condition=ready --timeout 300s
kubectl -n istio-system wait --for condition=available deployment.apps/istiod
kubectl -n istio-system wait --for condition=available deployment.apps/istio-ingressgateway
kubectl -n istio-system wait --for condition=available deployment.apps/istio-egressgateway
kubectl apply -f ./hack/istio-strict.yaml
kubectl -n $(OPERATOR_NAMESPACE) apply -f ./hack/istio-operator.yaml
kubectl label namespace $(OPERATOR_NAMESPACE) istio-injection=enabled --overwrite=true

# ----------------------------------------------------------------------------------------------------------------------
# Uninstall Istio
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: uninstall-istio
uninstall-istio: get-istio ## Uninstall Istio from k8s
kubectl -n $(OPERATOR_NAMESPACE) delete -f ./hack/istio-operator.yaml || true
kubectl delete -f ./hack/istio-strict.yaml
$(eval ISTIO_HOME := $(shell find $(TOOLS_DIRECTORY) -maxdepth 1 -type d | grep istio))
$(ISTIO_HOME)/bin/istioctl uninstall --purge -y

Expand Down
33 changes: 25 additions & 8 deletions api/v1/coherence_types.go
Expand Up @@ -451,6 +451,9 @@ func (in *CoherenceSpec) UpdatePodTemplateSpec(podTemplate *corev1.PodTemplateSp
c := EnsureContainerInPod(ContainerNameCoherence, podTemplate)
defer ReplaceContainerInPod(podTemplate, c)

lp, localPortAdjust := in.GetLocalPorts()
localPort := fmt.Sprintf("%d", lp)

if in == nil {
// we're nil so disable management and metrics/
c.Env = append(c.Env, corev1.EnvVar{Name: EnvVarCohMgmtPrefix + EnvVarCohEnabledSuffix, Value: "false"},
Expand All @@ -460,6 +463,9 @@ func (in *CoherenceSpec) UpdatePodTemplateSpec(podTemplate *corev1.PodTemplateSp
if deployment.GetType() == CoherenceTypeJob {
c.Env = append(c.Env, corev1.EnvVar{Name: EnvVarCohStorage, Value: "false"})
}

c.Env = append(c.Env, corev1.EnvVar{Name: EnvVarCoherenceLocalPort, Value: localPort})
c.Env = append(c.Env, corev1.EnvVar{Name: EnvVarCoherenceLocalPortAdjust, Value: localPortAdjust})
return
}

Expand All @@ -472,14 +478,8 @@ func (in *CoherenceSpec) UpdatePodTemplateSpec(podTemplate *corev1.PodTemplateSp
}

// Always set the unicast ports, as we default them if not specifically set
if in.LocalPort != nil {
c.Env = append(c.Env, corev1.EnvVar{Name: EnvVarCoherenceLocalPort, Value: Int32PtrToString(in.LocalPort)})
}

if in.LocalPortAdjust != nil {
lpa := in.LocalPortAdjust
c.Env = append(c.Env, corev1.EnvVar{Name: EnvVarCoherenceLocalPortAdjust, Value: lpa.String()})
}
c.Env = append(c.Env, corev1.EnvVar{Name: EnvVarCoherenceLocalPort, Value: localPort})
c.Env = append(c.Env, corev1.EnvVar{Name: EnvVarCoherenceLocalPortAdjust, Value: localPortAdjust})

if in.LogLevel != nil {
c.Env = append(c.Env, corev1.EnvVar{Name: EnvVarCohLogLevel, Value: Int32PtrToString(in.LogLevel)})
Expand Down Expand Up @@ -525,6 +525,23 @@ func (in *CoherenceSpec) UpdatePodTemplateSpec(podTemplate *corev1.PodTemplateSp
in.AddPersistenceVolumes(podTemplate)
}

// GetLocalPorts returns the Coherence local ports.
func (in *CoherenceSpec) GetLocalPorts() (int32, string) {
localPort := DefaultUnicastPort
localPortAdjust := fmt.Sprintf("%d", DefaultUnicastPortAdjust)
if in != nil {
if in.LocalPort != nil {
localPort = *in.LocalPort
}

if in.LocalPortAdjust != nil {
i := *in.LocalPortAdjust
localPortAdjust = i.String()
}
}
return localPort, localPortAdjust
}

// GetMetricsPort returns the metrics port number.
func (in *CoherenceSpec) GetMetricsPort() int32 {
switch {
Expand Down

0 comments on commit 16383c8

Please sign in to comment.