Skip to content

Commit d3d6d6b

Browse files
authored
Back port PR 3082 and 3092 to release/3.4 (#3149)
* Backport PR #3092 to release/3.4 * backport PR #3082 from main to releaase/3.4 * add scripts to pull and push images to local repo
1 parent 96485a6 commit d3d6d6b

File tree

8 files changed

+216
-25
lines changed

8 files changed

+216
-25
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItExternalLbTunneling.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import oracle.weblogic.domain.DomainSpec;
2525
import oracle.weblogic.domain.Model;
2626
import oracle.weblogic.domain.ServerPod;
27-
import oracle.weblogic.kubernetes.actions.impl.NginxParams;
2827
import oracle.weblogic.kubernetes.actions.impl.primitive.Command;
2928
import oracle.weblogic.kubernetes.actions.impl.primitive.CommandParams;
3029
import oracle.weblogic.kubernetes.actions.impl.primitive.HelmParams;
@@ -59,7 +58,6 @@
5958
import static oracle.weblogic.kubernetes.actions.TestActions.createDomainCustomResource;
6059
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
6160
import static oracle.weblogic.kubernetes.actions.TestActions.getServicePort;
62-
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallNginx;
6361
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallTraefik;
6462
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainExists;
6563
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
@@ -114,7 +112,6 @@ class ItExternalLbTunneling {
114112
private static String domainNamespace = null;
115113
private static String traefikNamespace = null;
116114
private static HelmParams traefikHelmParams = null;
117-
private static NginxParams nginxHelmParams = null;
118115
private static int replicaCount = 2;
119116
private static String clusterName = "cluster-1";
120117
private final String adminServerPodName = domainUid + "-admin-server";
@@ -572,13 +569,6 @@ public void tearDownAll() {
572569
.withFailMessage("uninstallTraefik() did not return true")
573570
.isTrue();
574571
}
575-
// uninstall NGINX
576-
if (nginxHelmParams != null) {
577-
assertThat(uninstallNginx(nginxHelmParams.getHelmParams()))
578-
.as("Test uninstallNginx returns true")
579-
.withFailMessage("uninstallNginx() did not return true")
580-
.isTrue();
581-
}
582572
}
583573
}
584574

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItOCILoadBalancer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private void verifyWebAppAccessThroughOCILoadBalancer(String lbIp, int replicaCo
163163
managedServerNames.add(MANAGED_SERVER_NAME_BASE + i);
164164
}
165165

166-
// check that NGINX can access the sample apps from all managed servers in the domain
166+
// check that LB can access the sample apps from all managed servers in the domain
167167
String curlCmd =
168168
String.format("curl --silent --show-error --noproxy '*' http://%s:%s/sample-war/index.jsp",
169169
lbIp,

integration-tests/src/test/java/oracle/weblogic/kubernetes/TestConstants.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,10 @@ public interface TestConstants {
176176
public static final String NGINX_REPO_NAME = "ingress-nginx";
177177
public static final String NGINX_CHART_NAME = "ingress-nginx";
178178
public static final String NGINX_CHART_VERSION = "4.0.17";
179-
public static final String NGINX_INGRESS_IMAGE_TAG = "v1.1.1";
180-
public static final String OCIR_NGINX_IMAGE_NAME = "weblogick8s/ingress-nginx/controller";
179+
public static final String NGINX_INGRESS_IMAGE_TAG = "v1.2.0";
180+
public static final String NGINX_INGRESS_IMAGE_DIGEST =
181+
"sha256:314435f9465a7b2973e3aa4f2edad7465cc7bcdc8304be5d146d70e4da136e51";
182+
public static final String OCIR_NGINX_IMAGE_NAME = "weblogick8s/test-images/ingress-nginx/controller";
181183
public static final String GCR_NGINX_IMAGE_NAME = "k8s.gcr.io/ingress-nginx/controller";
182184

183185
// Traefik constants

integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/NginxParams.java

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
import oracle.weblogic.kubernetes.actions.impl.primitive.HelmParams;
1111

12+
import static oracle.weblogic.kubernetes.TestConstants.NGINX_INGRESS_IMAGE_DIGEST;
13+
import static oracle.weblogic.kubernetes.TestConstants.NGINX_INGRESS_IMAGE_TAG;
14+
import static oracle.weblogic.kubernetes.TestConstants.OCIR_DEFAULT;
15+
import static oracle.weblogic.kubernetes.TestConstants.OCIR_NGINX_IMAGE_NAME;
16+
1217
/**
1318
* All parameters needed to install NGINX ingress controller.
1419
*/
@@ -21,13 +26,23 @@ public class NginxParams {
2126
private static final String NODEPORTS_HTTPS = "controller.service.nodePorts.https";
2227
private static final String ADMISSIONWEBHOOKS_ENABLED = "controller.admissionWebhooks.enabled";
2328
private static final String INGRESS_CLASS_NAME = "controller.ingressClassResource.name";
29+
private static final String NGINX_IMAGE_REGISTRY = "controller.image.registry";
30+
private static final String NGINX_IMAGE = "controller.image.image";
31+
private static final String NGINX_IMAGE_TAG = "controller.image.tag";
32+
private static final String NGINX_IMAGE_DIGEST = "controller.image.digest";
33+
private static final String IMAGE_PULL_SECRET = "imagePullSecrets[0].name";
2434

2535
// Adding some of the most commonly used params for now
2636
private int nodePortsHttp;
2737
private int nodePortsHttps;
2838
private boolean webhooksEnabled = false;
2939
private HelmParams helmParams;
3040
private String ingressClassName;
41+
private String imageRegistry = OCIR_DEFAULT;
42+
private String nginxImage = OCIR_NGINX_IMAGE_NAME;
43+
private String nginxImageTag = NGINX_INGRESS_IMAGE_TAG;
44+
private String nginxImageDigest = NGINX_INGRESS_IMAGE_DIGEST;
45+
private String imageRepoSecret;
3146

3247
public NginxParams() {
3348
ingressClassName = UniqueName.uniqueName("nginx-");
@@ -52,15 +67,40 @@ public String getIngressClassName() {
5267
return ingressClassName;
5368
}
5469

55-
public NginxParams helmParams(HelmParams helmParams) {
56-
this.helmParams = helmParams;
70+
public HelmParams getHelmParams() {
71+
return helmParams;
72+
}
73+
74+
public NginxParams imageRegistry(String imageRegistry) {
75+
this.imageRegistry = imageRegistry;
5776
return this;
5877
}
5978

60-
public HelmParams getHelmParams() {
61-
return helmParams;
79+
public NginxParams nginxImage(String nginxImage) {
80+
this.nginxImage = nginxImage;
81+
return this;
6282
}
6383

84+
public NginxParams nginxImageTag(String nginxImageTag) {
85+
this.nginxImageTag = nginxImageTag;
86+
return this;
87+
}
88+
89+
public NginxParams nginxImageDigest(String nginxImageDigest) {
90+
this.nginxImageDigest = nginxImageDigest;
91+
return this;
92+
}
93+
94+
public NginxParams imageRepoSecret(String imageRepoSecret) {
95+
this.imageRepoSecret = imageRepoSecret;
96+
return this;
97+
}
98+
99+
public NginxParams helmParams(HelmParams helmParams) {
100+
this.helmParams = helmParams;
101+
return this;
102+
}
103+
64104
/**
65105
* Loads Helm values into a value map.
66106
*
@@ -78,8 +118,16 @@ public Map<String, Object> getValues() {
78118

79119
values.put(ADMISSIONWEBHOOKS_ENABLED, webhooksEnabled);
80120
values.put(INGRESS_CLASS_NAME, ingressClassName);
81-
121+
values.put(NGINX_IMAGE_REGISTRY, imageRegistry);
122+
values.put(NGINX_IMAGE, nginxImage);
123+
values.put(NGINX_IMAGE_TAG, nginxImageTag);
124+
values.put(NGINX_IMAGE_DIGEST, nginxImageDigest);
125+
126+
if (imageRepoSecret != null) {
127+
values.put(IMAGE_PULL_SECRET, imageRepoSecret);
128+
}
129+
82130
values.values().removeIf(Objects::isNull);
83131
return values;
84132
}
85-
}
133+
}

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/LoadBalancerUtils.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@
4444
import static oracle.weblogic.kubernetes.TestConstants.NGINX_RELEASE_NAME;
4545
import static oracle.weblogic.kubernetes.TestConstants.NGINX_REPO_NAME;
4646
import static oracle.weblogic.kubernetes.TestConstants.NGINX_REPO_URL;
47+
import static oracle.weblogic.kubernetes.TestConstants.OCIR_EMAIL;
48+
import static oracle.weblogic.kubernetes.TestConstants.OCIR_PASSWORD;
49+
import static oracle.weblogic.kubernetes.TestConstants.OCIR_REGISTRY;
4750
import static oracle.weblogic.kubernetes.TestConstants.OCIR_SECRET_NAME;
51+
import static oracle.weblogic.kubernetes.TestConstants.OCIR_USERNAME;
4852
import static oracle.weblogic.kubernetes.TestConstants.RESULTS_ROOT;
4953
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_CHART_NAME;
5054
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_RELEASE_NAME;
@@ -72,6 +76,7 @@
7276
import static oracle.weblogic.kubernetes.assertions.TestAssertions.secretExists;
7377
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReady;
7478
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
79+
import static oracle.weblogic.kubernetes.utils.ImageUtils.createDockerRegistrySecret;
7580
import static oracle.weblogic.kubernetes.utils.ImageUtils.createOcirRepoSecret;
7681
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
7782
import static org.assertj.core.api.Assertions.assertThat;
@@ -167,6 +172,8 @@ public static NginxParams installAndVerifyNginx(String nginxNamespace,
167172
String chartVersion) {
168173
LoggingFacade logger = getLogger();
169174
// Helm install parameters
175+
createDockerRegistrySecret(OCIR_USERNAME, OCIR_PASSWORD, OCIR_EMAIL,
176+
OCIR_REGISTRY, OCIR_SECRET_NAME, nginxNamespace);
170177
HelmParams nginxHelmParams = new HelmParams()
171178
.releaseName(NGINX_RELEASE_NAME + "-" + nginxNamespace.substring(3))
172179
.namespace(nginxNamespace)
@@ -181,7 +188,10 @@ public static NginxParams installAndVerifyNginx(String nginxNamespace,
181188
// NGINX chart values to override
182189
NginxParams nginxParams = new NginxParams()
183190
.helmParams(nginxHelmParams);
184-
191+
192+
// set secret to pull images from private registry
193+
nginxParams.imageRepoSecret(OCIR_SECRET_NAME);
194+
185195
if (nodeportshttp != 0 && nodeportshttps != 0) {
186196
nginxParams
187197
.nodePortsHttp(nodeportshttp)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Absolute Source Image Location; Target Image Location w.r.t. Test reposiotory
2+
3+
# WebLogic Release 14.1.1.0
4+
container-registry.oracle.com/middleware/weblogic:14.1.1.0-11;weblogick8s/test-images/weblogic:14.1.1.0-11
5+
container-registry.oracle.com/middleware/weblogic:14.1.1.0-11-ol8;weblogick8s/test-images/weblogic:14.1.1.0-11-ol8
6+
7+
container-registry.oracle.com/middleware/weblogic:14.1.1.0-8;weblogick8s/test-images/weblogic:14.1.1.0-8
8+
container-registry.oracle.com/middleware/weblogic:14.1.1.0-8-ol8;weblogick8s/test-images/weblogic:14.1.1.0-8-ol8
9+
10+
container-registry.oracle.com/middleware/weblogic:14.1.1.0-slim-11;weblogick8s/test-images/weblogic:14.1.1.0-slim-11
11+
container-registry.oracle.com/middleware/weblogic:14.1.1.0-slim-11-ol8;weblogick8s/test-images/weblogic:14.1.1.0-slim-11-ol8
12+
13+
container-registry.oracle.com/middleware/weblogic:14.1.1.0-slim-8;weblogick8s/test-images/weblogic:14.1.1.0-slim-8
14+
container-registry.oracle.com/middleware/weblogic:14.1.1.0-slim-8-ol8;weblogick8s/test-images/weblogic:14.1.1.0-slim-8-ol8
15+
16+
container-registry.oracle.com/middleware/weblogic:14.1.1.0-dev-11;weblogick8s/test-images/weblogic:14.1.1.0-dev-11
17+
container-registry.oracle.com/middleware/weblogic:14.1.1.0-dev-11-ol8;weblogick8s/test-images/weblogic:14.1.1.0-dev-11-ol8
18+
19+
container-registry.oracle.com/middleware/weblogic:14.1.1.0-dev-8;weblogick8s/test-images/weblogic:14.1.1.0-dev-8
20+
container-registry.oracle.com/middleware/weblogic:14.1.1.0-dev-8-ol8;weblogick8s/test-images/weblogic:14.1.1.0-dev-8-ol8
21+
22+
# WebLogic Release 12.2.1.4
23+
24+
container-registry.oracle.com/middleware/weblogic:12.2.1.4;weblogick8s/test-images/weblogic:12.2.1.4
25+
container-registry.oracle.com/middleware/weblogic:12.2.1.4-ol8;weblogick8s/test-images/weblogic:12.2.1.4-ol8
26+
27+
container-registry.oracle.com/middleware/weblogic:12.2.1.4-slim;weblogick8s/test-images/weblogic:12.2.1.4-slim
28+
container-registry.oracle.com/middleware/weblogic:12.2.1.4-slim-ol8;weblogick8s/test-images/weblogic:12.2.1.4-slim-ol8
29+
30+
container-registry.oracle.com/middleware/weblogic:12.2.1.4-dev;weblogick8s/test-images/weblogic:12.2.1.4-dev
31+
container-registry.oracle.com/middleware/weblogic:12.2.1.4-dev-ol8;weblogick8s/test-images/weblogic:12.2.1.4-dev-ol8
32+
33+
# WebLogic Release 12.2.1.3
34+
35+
container-registry.oracle.com/middleware/weblogic:12.2.1.3;weblogick8s/test-images/weblogic:12.2.1.3
36+
container-registry.oracle.com/middleware/weblogic:12.2.1.3-ol8;weblogick8s/test-images/weblogic:12.2.1.3-ol8
37+
38+
container-registry.oracle.com/middleware/weblogic:12.2.1.3-dev;weblogick8s/test-images/weblogic:12.2.1.3-dev
39+
container-registry.oracle.com/middleware/weblogic:12.2.1.3-dev-ol8;weblogick8s/test-images/weblogic:12.2.1.3-dev-ol8
40+
41+
# FMW Release 12.2.1.4
42+
43+
container-registry.oracle.com/middleware/fmw-infrastructure:12.2.1.4;weblogick8s/test-images/fmw-infrastructure:12.2.1.4
44+
container-registry.oracle.com/middleware/fmw-infrastructure:12.2.1.4-ol8;weblogick8s/test-images/fmw-infrastructure:12.2.1.4-ol8
45+
46+
# FMW Release 12.2.1.3
47+
container-registry.oracle.com/middleware/fmw-infrastructure:12.2.1.3;weblogick8s/test-images/fmw-infrastructure:12.2.1.3
48+
container-registry.oracle.com/middleware/fmw-infrastructure:12.2.1.3-ol8;weblogick8s/test-images/fmw-infrastructure:12.2.1.3-ol8
49+
50+
# Oracle DB Image Release 12.2.0.1-slim
51+
container-registry.oracle.com/database/enterprise:12.2.0.1-slim;weblogick8s/test-images/database/enterprise:12.2.0.1-slim
52+
53+
# BusyBox
54+
busybox:1.34.1;weblogick8s/test-images/docker/busybox:1.34.1
55+
56+
# NGINX Controller
57+
k8s.gcr.io/ingress-nginx/controller:v1.2.0;weblogick8s/test-images/ingress-nginx/controller:v1.2.0
58+
59+
# Oracle DB Operator Image
60+
container-registry.oracle.com/database/operator:0.1.0;weblogick8s/test-images/database/operator:0.1.0

integration-tests/src/test/resources/bash-scripts/install-istio.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,19 @@ istiodir=${workdir}/istio-${version}
2727
echo "Installing Istio version [${version}] in location [${istiodir}]"
2828

2929
kubectl delete namespace istio-system --ignore-not-found
30-
# istio installation will create the namespace 'istio-system'
31-
# kubectl create namespace istio-system
30+
# create the namespace 'istio-system'
31+
kubectl create namespace istio-system
3232

33-
( cd $workdir;
34-
curl -L https://istio.io/downloadIstio | ISTIO_VERSION=${version} TARGET_ARCH=x86_64 sh -
33+
( cd $workdir;
34+
curl -Lo "istio.tar.gz" "https://objectstorage.us-phoenix-1.oraclecloud.com/n/weblogick8s/b/wko-system-test-files/o/istio%2Fistio-${version}-linux-amd64.tar.gz";
35+
tar zxf istio.tar.gz
3536
)
3637

38+
( kubectl create secret generic docker-istio-secret --type=kubernetes.io/dockerconfigjson --from-file=.dockerconfigjson=$HOME/.docker/config.json -n istio-system )
39+
3740
( cd ${istiodir}
3841
bin/istioctl x precheck
39-
bin/istioctl install --set profile=demo --set hub=gcr.io/istio-release --set meshConfig.enablePrometheusMerge=false -y
42+
bin/istioctl install --set profile=demo --set values.global.imagePullSecrets[0]=docker-istio-secret --set meshConfig.enablePrometheusMerge=false -y
4043
bin/istioctl verify-install
4144
bin/istioctl version
4245
)
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
# Copyright (c) 2022, Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
5+
set -eu
6+
set -o pipefail
7+
8+
function dockerLogin() {
9+
10+
echo "docker login to src ${SOURCE_REPO}"
11+
echo ${SOURCE_PASSWORD} > pwd.txt
12+
cat pwd.txt | docker login ${SOURCE_REPO} -u ${SOURCE_USER} --password-stdin
13+
rm -rf pwd.txt
14+
15+
# Alternatively use
16+
# docker login ${SOURCE_REPO} -u ${SOURCE_USER} -p ${SOURCE_PASSWORD}
17+
18+
echo "docker login to target ${TARGET_REPO}"
19+
echo ${TARGET_PASSWORD} > pwd.txt
20+
cat pwd.txt | docker login ${TARGET_REPO} -u ${TARGET_USER} --password-stdin
21+
rm -rf pwd.txt
22+
23+
}
24+
25+
function dockerPullPushImage() {
26+
27+
# Here the source image contains absolute image path
28+
# and source image contains relative path wrt to TARGET_REPO
29+
30+
src_image="${1}"
31+
tgt_image="${TARGET_REPO}/${2}"
32+
33+
printf 'SRC[%s] TARGET[%s] \n' "${src_image}" "${tgt_image}"
34+
35+
docker pull ${src_image}
36+
docker tag ${src_image} ${tgt_image}
37+
docker push ${tgt_image}
38+
39+
docker rmi -f ${src_image}
40+
docker rmi -f ${tgt_image}
41+
}
42+
43+
function dockerPullPushImages {
44+
file="images.properties"
45+
egrep -v '^#' $file | grep -v "^$" |
46+
while IFS=";" read -r f1 f2
47+
do
48+
# printf 'Source Location : [%s], Target: [%s] \n' "$f1" "$f2"
49+
dockerPullPushImage $f1 $f2
50+
done
51+
}
52+
53+
#MAIN
54+
55+
if [ $# -ge 1 ]; then
56+
echo "Export the following Environment varaiables before running the script"
57+
echo " SOURCE_REPO(ocr), SOURCE_USER, SOURCE_PASSWORD (Base Image repository)"
58+
echo " TARGET_REPO(ocir), TARGET_USER, TARGET_PASSWORD (Target Image repository)"
59+
exit 0
60+
fi
61+
62+
SOURCE_REPO=${SOURCE_REPO:-container-registry.oracle.com}
63+
SOURCE_USER=${SOURCE_USER:-oracle}
64+
SOURCE_PASSWORD=${SOURCE_PASSWORD:-changeme}
65+
66+
TARGET_REPO=${TARGET_REPO:-phx.ocir.io}
67+
TARGET_USER=${TARGET_USER:-oracle}
68+
TARGET_PASSWORD=${TARGET_PASSWORD:-changeme}
69+
70+
echo "SOURCE_REPO[$SOURCE_REPO] and TARGET_REPO[${TARGET_REPO}]"
71+
72+
if [ ${SOURCE_REPO} == ${TARGET_REPO} ]; then
73+
echo "SOURCE_REPO[$SOURCE_REPO], TARGET_REPO[${TARGET_REPO}] can't be same"
74+
exit -1
75+
fi
76+
77+
dockerLogin
78+
dockerPullPushImages

0 commit comments

Comments
 (0)