From d1b94a8f184cc09592741896688f18823921d117 Mon Sep 17 00:00:00 2001 From: Gilbert Kwan Date: Fri, 23 Feb 2024 13:55:19 -0500 Subject: [PATCH] Update to MP6.1 (#190) * updated readme * update versions * update versions --------- Co-authored-by: t27gupta --- .github/dependabot.yml | 7 ++++++ .github/workflows/add-pr-to-project.yml | 18 ++++++++++++++ README.adoc | 24 ++++++++++++++----- finish/inventory/pom.xml | 4 ++-- .../guides/inventory/client/SystemClient.java | 8 +++---- .../health/InventoryReadinessCheck.java | 4 ++-- .../src/main/liberty/config/server.xml | 10 ++++---- finish/inventory/src/main/webapp/index.html | 6 ++--- finish/kubernetes.yaml | 24 +++++++++---------- finish/system/pom.xml | 4 ++-- .../system/src/main/liberty/config/server.xml | 10 ++++---- finish/system/src/main/webapp/index.html | 6 ++--- start/inventory/pom.xml | 4 ++-- .../guides/inventory/client/SystemClient.java | 8 +++---- .../health/InventoryReadinessCheck.java | 4 ++-- .../src/main/liberty/config/server.xml | 10 ++++---- start/inventory/src/main/webapp/index.html | 6 ++--- start/kubernetes.yaml | 24 +++++++++---------- start/system/pom.xml | 4 ++-- .../system/src/main/liberty/config/server.xml | 10 ++++---- start/system/src/main/webapp/index.html | 6 ++--- 21 files changed, 119 insertions(+), 82 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/add-pr-to-project.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..00dad748 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: +- package-ecosystem: maven + directory: "/" + schedule: + interval: monthly + open-pull-requests-limit: 50 diff --git a/.github/workflows/add-pr-to-project.yml b/.github/workflows/add-pr-to-project.yml new file mode 100644 index 00000000..0b1643a7 --- /dev/null +++ b/.github/workflows/add-pr-to-project.yml @@ -0,0 +1,18 @@ +name: Add PRs to Dependabot PRs dashboard + +on: + pull_request: + types: + - opened + - labeled + +jobs: + add-to-project: + name: Add PR to dashboard + runs-on: ubuntu-latest + steps: + - uses: actions/add-to-project@v0.5.0 + with: + project-url: https://github.com/orgs/OpenLiberty/projects/26 + github-token: ${{ secrets.ADMIN_BACKLOG }} + labeled: dependencies diff --git a/README.adoc b/README.adoc index dd88556c..fac0187f 100644 --- a/README.adoc +++ b/README.adoc @@ -1,4 +1,4 @@ -// Copyright (c) 2018, 2023 IBM Corporation and others. +// Copyright (c) 2018, 2024 IBM Corporation and others. // Licensed under Creative Commons Attribution-NoDerivatives // 4.0 International (CC BY-ND 4.0) // https://creativecommons.org/licenses/by-nd/4.0/ @@ -11,7 +11,7 @@ :page-duration: 15 minutes :page-releasedate: 2018-10-12 :page-description: Externalize configuration and use Kubernetes ConfigMaps and Secrets to configure your microservices. -:page-tags: ['Kubernetes', 'Docker', 'MicroProfile'] +:page-tags: ['kubernetes', 'docker', 'microprofile'] :page-permalink: /guides/{projectid} :page-related-guides: ['kubernetes-intro', 'microprofile-config', 'cdi-intro', 'docker'] :common-includes: https://raw.githubusercontent.com/OpenLiberty/guides-common/prod @@ -204,13 +204,13 @@ ifdef::cloud-hosted[] In this IBM cloud environment, you need to set up port forwarding to access the services. Open another command-line session by selecting **Terminal** > **New Terminal** from the menu of the IDE. Run the following commands to set up port forwarding to access the **system** service. ```bash SYSTEM_NODEPORT=`kubectl get -o jsonpath="{.spec.ports[0].nodePort}" services system-service` -kubectl port-forward svc/system-service $SYSTEM_NODEPORT:9080 +kubectl port-forward svc/system-service $SYSTEM_NODEPORT:9090 ``` Then, open another command-line session by selecting **Terminal** > **New Terminal** from the menu of the IDE. Run the following commands to set up port forwarding to access the **inventory** service. ```bash INVENTORY_NODEPORT=`kubectl get -o jsonpath="{.spec.ports[0].nodePort}" services inventory-service` -kubectl port-forward svc/inventory-service $INVENTORY_NODEPORT:9080 +kubectl port-forward svc/inventory-service $INVENTORY_NODEPORT:9090 ``` Then use the following commands to access your **system** microservice. The ***-u*** option is used to pass in the username ***bob*** and the password ***bobpwd***. @@ -293,6 +293,12 @@ kubectl create configmap sys-app-root --from-literal contextRoot=/dev This command deploys a ConfigMap named `sys-app-root` to your cluster. It has a key called `contextRoot` with a value of `/dev`. The `--from-literal` flag allows you to specify individual key-value pairs to store in this ConfigMap. Other available options, such as `--from-file` and `--from-env-file`, provide more versatility as to what you want to configure. Details about these options can be found in the https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-configmap-em-[{kube} CLI documentation^]. +Run the following command to display details of the ConfigMap. +[role='command'] +``` +kubectl describe configmaps sys-app-root +``` + Create a Secret to configure the new credentials that `inventory` uses to authenticate against `system` with the following `kubectl` command. [role='command'] ``` @@ -301,6 +307,12 @@ kubectl create secret generic sys-app-credentials --from-literal username=alice This command looks similar to the command to create a ConfigMap, but one difference is the word `generic`. This word creates a Secret that doesn't store information in any specialized way. Different types of secrets are available, such as secrets to store Docker credentials and secrets to store public and private key pairs. +Run the following command to display details of the Secret. +[role='command'] +``` +kubectl describe secrets/sys-app-credentials +``` + A Secret is similar to a ConfigMap. A key difference is that a Secret is used for confidential information such as credentials. One of the main differences is that you must explicitly tell `kubectl` to show you the contents of a Secret. Additionally, when it does show you the information, it only shows you a Base64 encoded version so that a casual onlooker doesn't accidentally see any sensitive data. Secrets don't provide any encryption by default, that is something you'll either need to do yourself or find an alternate option to configure. Encryption is not required for the application to run. kubernetes.yaml @@ -441,14 +453,14 @@ Run the following commands to set up port forwarding to access the ***system*** ```bash SYSTEM_NODEPORT=`kubectl get -o jsonpath="{.spec.ports[0].nodePort}" services system-service` -kubectl port-forward svc/system-service $SYSTEM_NODEPORT:9080 +kubectl port-forward svc/system-service $SYSTEM_NODEPORT:9090 ``` Then, run the following commands to set up port forwarding to access the **inventory** service. ```bash INVENTORY_NODEPORT=`kubectl get -o jsonpath="{.spec.ports[0].nodePort}" services inventory-service` -kubectl port-forward svc/inventory-service $INVENTORY_NODEPORT:9080 +kubectl port-forward svc/inventory-service $INVENTORY_NODEPORT:9090 ``` You now need to use the new username, ***alice***, and the new password, ***wonderland***, to log in. Access your application with the following commands: diff --git a/finish/inventory/pom.xml b/finish/inventory/pom.xml index 78daa7ab..cecb7d1c 100644 --- a/finish/inventory/pom.xml +++ b/finish/inventory/pom.xml @@ -19,8 +19,8 @@ localhost:31000 localhost:32000 - 9080 - 9443 + 9090 + 9453 diff --git a/finish/inventory/src/main/java/io/openliberty/guides/inventory/client/SystemClient.java b/finish/inventory/src/main/java/io/openliberty/guides/inventory/client/SystemClient.java index e0fed2b5..952ef304 100644 --- a/finish/inventory/src/main/java/io/openliberty/guides/inventory/client/SystemClient.java +++ b/finish/inventory/src/main/java/io/openliberty/guides/inventory/client/SystemClient.java @@ -1,6 +1,6 @@ // tag::copyright[] /******************************************************************************* - * Copyright (c) 2017, 2023 IBM Corporation and others. + * Copyright (c) 2017, 2024 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -41,8 +41,8 @@ public class SystemClient { // end::context-root[] @Inject - @ConfigProperty(name = "default.http.port") - String DEFAULT_PORT; + @ConfigProperty(name = "http.port") + String HTTP_PORT; // Basic Auth Credentials // tag::credentials[] @@ -79,7 +79,7 @@ public Properties getProperties(String hostname) { private Builder getBuilder(String hostname, Client client) throws Exception { // tag::context-root1[] URI uri = new URI( - PROTOCOL, null, hostname, Integer.valueOf(DEFAULT_PORT), + PROTOCOL, null, hostname, Integer.valueOf(HTTP_PORT), CONTEXT_ROOT + SYSTEM_PROPERTIES, null, null); // end::context-root1[] String urlString = uri.toString(); diff --git a/finish/inventory/src/main/java/io/openliberty/guides/inventory/health/InventoryReadinessCheck.java b/finish/inventory/src/main/java/io/openliberty/guides/inventory/health/InventoryReadinessCheck.java index 23c27ec2..c2c80575 100644 --- a/finish/inventory/src/main/java/io/openliberty/guides/inventory/health/InventoryReadinessCheck.java +++ b/finish/inventory/src/main/java/io/openliberty/guides/inventory/health/InventoryReadinessCheck.java @@ -1,6 +1,6 @@ // tag::copyright[] /******************************************************************************* - * Copyright (c) 2022 IBM Corporation and others. + * Copyright (c) 2022, 2024 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -45,7 +45,7 @@ private boolean isSystemServiceReachable() { try { Client client = ClientBuilder.newClient(); client - .target("http://" + hostname + ":9080/system/properties") + .target("http://" + hostname + ":9090/system/properties") .request() .post(null); diff --git a/finish/inventory/src/main/liberty/config/server.xml b/finish/inventory/src/main/liberty/config/server.xml index c5d077c8..26bfb947 100755 --- a/finish/inventory/src/main/liberty/config/server.xml +++ b/finish/inventory/src/main/liberty/config/server.xml @@ -4,16 +4,16 @@ restfulWS-3.1 jsonb-3.0 cdi-4.0 - mpConfig-3.0 + mpConfig-3.1 jsonp-2.1 mpHealth-4.0 - - + + - + diff --git a/finish/inventory/src/main/webapp/index.html b/finish/inventory/src/main/webapp/index.html index dedf6fd1..a18a66eb 100755 --- a/finish/inventory/src/main/webapp/index.html +++ b/finish/inventory/src/main/webapp/index.html @@ -1,5 +1,5 @@ - 9080 - 9443 + 9090 + 9453 diff --git a/finish/system/src/main/liberty/config/server.xml b/finish/system/src/main/liberty/config/server.xml index 1cf3025c..6f25cd60 100755 --- a/finish/system/src/main/liberty/config/server.xml +++ b/finish/system/src/main/liberty/config/server.xml @@ -5,21 +5,21 @@ jsonb-3.0 cdi-4.0 jsonp-2.1 - mpConfig-3.0 + mpConfig-3.1 mpHealth-4.0 appSecurity-5.0 - - + + - + diff --git a/finish/system/src/main/webapp/index.html b/finish/system/src/main/webapp/index.html index ae1f1f10..6ddeddad 100755 --- a/finish/system/src/main/webapp/index.html +++ b/finish/system/src/main/webapp/index.html @@ -1,5 +1,5 @@ - 9080 - 9443 + 9090 + 9453 diff --git a/start/inventory/src/main/java/io/openliberty/guides/inventory/client/SystemClient.java b/start/inventory/src/main/java/io/openliberty/guides/inventory/client/SystemClient.java index f630cbf9..f19826e4 100644 --- a/start/inventory/src/main/java/io/openliberty/guides/inventory/client/SystemClient.java +++ b/start/inventory/src/main/java/io/openliberty/guides/inventory/client/SystemClient.java @@ -1,6 +1,6 @@ // tag::copyright[] /******************************************************************************* - * Copyright (c) 2017, 2022 IBM Corporation and others. + * Copyright (c) 2017, 2024 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -35,8 +35,8 @@ public class SystemClient { private final String PROTOCOL = "http"; @Inject - @ConfigProperty(name = "default.http.port") - String DEFAULT_PORT; + @ConfigProperty(name = "http.port") + String HTTP_PORT; // Basic Auth Credentials private String username = "bob"; @@ -61,7 +61,7 @@ public Properties getProperties(String hostname) { // Method that creates the client builder private Builder getBuilder(String hostname, Client client) throws Exception { URI uri = new URI( - PROTOCOL, null, hostname, Integer.valueOf(DEFAULT_PORT), + PROTOCOL, null, hostname, Integer.valueOf(HTTP_PORT), SYSTEM_PROPERTIES, null, null); String urlString = uri.toString(); Builder builder = client.target(urlString).request(); diff --git a/start/inventory/src/main/java/io/openliberty/guides/inventory/health/InventoryReadinessCheck.java b/start/inventory/src/main/java/io/openliberty/guides/inventory/health/InventoryReadinessCheck.java index 23c27ec2..c2c80575 100644 --- a/start/inventory/src/main/java/io/openliberty/guides/inventory/health/InventoryReadinessCheck.java +++ b/start/inventory/src/main/java/io/openliberty/guides/inventory/health/InventoryReadinessCheck.java @@ -1,6 +1,6 @@ // tag::copyright[] /******************************************************************************* - * Copyright (c) 2022 IBM Corporation and others. + * Copyright (c) 2022, 2024 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -45,7 +45,7 @@ private boolean isSystemServiceReachable() { try { Client client = ClientBuilder.newClient(); client - .target("http://" + hostname + ":9080/system/properties") + .target("http://" + hostname + ":9090/system/properties") .request() .post(null); diff --git a/start/inventory/src/main/liberty/config/server.xml b/start/inventory/src/main/liberty/config/server.xml index 3f35bdf4..251c78ca 100755 --- a/start/inventory/src/main/liberty/config/server.xml +++ b/start/inventory/src/main/liberty/config/server.xml @@ -4,16 +4,16 @@ restfulWS-3.1 jsonb-3.0 cdi-4.0 - mpConfig-3.0 + mpConfig-3.1 mpHealth-4.0 jsonp-2.1 - - + + - + diff --git a/start/inventory/src/main/webapp/index.html b/start/inventory/src/main/webapp/index.html index dedf6fd1..a18a66eb 100755 --- a/start/inventory/src/main/webapp/index.html +++ b/start/inventory/src/main/webapp/index.html @@ -1,5 +1,5 @@ localhost:31000 - 9080 - 9443 + 9090 + 9453 diff --git a/start/system/src/main/liberty/config/server.xml b/start/system/src/main/liberty/config/server.xml index 0c0e6d46..9f71a5de 100644 --- a/start/system/src/main/liberty/config/server.xml +++ b/start/system/src/main/liberty/config/server.xml @@ -5,18 +5,18 @@ jsonb-3.0 cdi-4.0 jsonp-2.1 - mpConfig-3.0 + mpConfig-3.1 mpHealth-4.0 appSecurity-5.0 - - + + - + diff --git a/start/system/src/main/webapp/index.html b/start/system/src/main/webapp/index.html index ae1f1f10..6ddeddad 100755 --- a/start/system/src/main/webapp/index.html +++ b/start/system/src/main/webapp/index.html @@ -1,5 +1,5 @@