diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8721c488d24840b3f2055ae7b1fe3b70432e0685..32bd84fc706eb0b8b18990f195f0f35ae442a3e4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,12 @@ variables: AWS_SERVICE: notification AWS_ENVIRONMENT: dev + AZURE_SERVICE: notification + AZURE_BUILD_SUBDIR: provider/notification-azure + AZURE_TEST_SUBDIR: testing/notification-test-core + AZURE_SKIP_TEST: 'true' + AZURE_DEPLOYMENTS_SUBDIR: deployments/scripts/azure + include: - project: 'osdu/platform/ci-cd-pipelines' ref: 'master' @@ -26,6 +32,10 @@ include: ref: 'master' file: 'scanners/gitlab-ultimate.yml' + - project: "osdu/platform/ci-cd-pipelines" + ref: 'master' + file: "cloud-providers/azure.yml" + - project: 'osdu/platform/ci-cd-pipelines' ref: 'master' file: 'cloud-providers/osdu-gcp-cloudrun.yml' diff --git a/devops/azure/README.md b/devops/azure/README.md new file mode 100644 index 0000000000000000000000000000000000000000..55316bc3194139d3836da5619e48055c27f0cd7e --- /dev/null +++ b/devops/azure/README.md @@ -0,0 +1,17 @@ +# Pipeline Support Commands + +```bash +AZURE_SERVICE="notification" +REPO_BRANCH="master" +TAG="latest" +PARTIAL=${REPO_BRANCH/\//-} +BRANCH=${PARTIAL/./-} + +echo "--set image.branch=$BRANCH --set image.tag=$TAG" + +# Install the Service +helm upgrade -i osdu-gitlab-$AZURE_SERVICE chart --set image.branch=$BRANCH --set image.tag=$TAG +pod=$(kubectl get pod |grep $AZURE_SERVICE | tail -1 | awk '{print $1}') +status=$(kubectl wait --for=condition=Ready pod/$pod --timeout=60s) +if [[ "$status" != *"met"* ]]; then echo "POD didn't start correctly" ; exit 1 ; fi +``` diff --git a/devops/azure/chart/Chart.yaml b/devops/azure/chart/Chart.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b65147e73bff1ec02cc5cd65a9241cf1119ae8fa --- /dev/null +++ b/devops/azure/chart/Chart.yaml @@ -0,0 +1,20 @@ +# Copyright © Microsoft Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v1 +name: notification +appVersion: "latest" +description: Helm Chart for installing notification service. +version: 0.1.0 +type: application diff --git a/devops/azure/chart/templates/auth.yaml b/devops/azure/chart/templates/auth.yaml new file mode 100644 index 0000000000000000000000000000000000000000..81b9c11de6829209be551126f0361db503eec31a --- /dev/null +++ b/devops/azure/chart/templates/auth.yaml @@ -0,0 +1,33 @@ +# Source: istio/templates/notification.yaml +# Copyright © Microsoft Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: notification-jwt-authz + namespace: osdu +spec: + selector: + matchLabels: + app: notification + action: DENY + rules: + - from: + - source: + notRequestPrincipals: ["*"] + to: + - operation: + notPaths: ["/","*/swagger-resources","*/swagger", + "/api/notification/v1/swagger-resources/*","*/swagger-ui.html","*/actuator/health"] \ No newline at end of file diff --git a/devops/azure/chart/templates/deployment.yaml b/devops/azure/chart/templates/deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..af7918321276d8aacf7ae82378167cdffc219fb5 --- /dev/null +++ b/devops/azure/chart/templates/deployment.yaml @@ -0,0 +1,96 @@ +# Copyright © Microsoft Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }} + namespace: osdu +spec: + replicas: {{ .Values.global.replicaCount }} + selector: + matchLabels: + app: {{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Chart.Name }} + aadpodidbinding: osdu-identity + spec: + volumes: + - name: azure-keyvault + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: azure-keyvault + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image.repository }}/{{ .Chart.Name }}-{{ .Values.image.branch }}:{{ .Values.image.tag | default .Chart.AppVersion }} + imagePullPolicy: Always + ports: + - containerPort: 80 + readinessProbe: + httpGet: + path: /api/notification/v1/swagger-ui.html + port: 80 + volumeMounts: + - name: azure-keyvault + mountPath: "/mnt/azure-keyvault" + readOnly: true + env: + - name: spring_application_name + value: notification-azure + - name: server.servlet.contextPath + value: /api/notification/v1 + - name: server_port + value: "80" + - name: KEYVAULT_URI + valueFrom: + configMapKeyRef: + name: osdu-svc-properties + key: ENV_KEYVAULT + - name: AZURE_TENANT_ID + valueFrom: + secretKeyRef: + name: active-directory + key: tenantid + - name: AZURE_CLIENT_ID + valueFrom: + secretKeyRef: + name: active-directory + key: principal-clientid + - name: AZURE_CLIENT_SECRET + valueFrom: + secretKeyRef: + name: active-directory + key: principal-clientpassword + - name: aad_client_id + valueFrom: + secretKeyRef: + name: active-directory + key: application-appid + - name: appinsights_key + valueFrom: + secretKeyRef: + name: central-logging + key: appinsights + - name: cosmosdb_database + value: osdu-db + - name: entitlements_service_endpoint + value: http://entitlements-azure/entitlements/v1 + - name: registeration_service_endpoint + value: http://register/api/register/v1 + - name: maxCacheSize + value: "20" \ No newline at end of file diff --git a/devops/azure/chart/templates/service.yaml b/devops/azure/chart/templates/service.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2df46074c077d233c6706cc7179c2c2c47d7a218 --- /dev/null +++ b/devops/azure/chart/templates/service.yaml @@ -0,0 +1,27 @@ +# Copyright © Microsoft Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} + namespace: osdu +spec: + type: ClusterIP + ports: + - protocol: TCP + port: 80 + targetPort: 80 + selector: + app: {{ .Chart.Name }} \ No newline at end of file diff --git a/devops/azure/chart/values.yaml b/devops/azure/chart/values.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d503dd73deaa4d89c63c0bc034cac4354c4970b2 --- /dev/null +++ b/devops/azure/chart/values.yaml @@ -0,0 +1,21 @@ +# Copyright © Microsoft Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +global: + replicaCount: 1 + +image: + repository: community.opengroup.org:5555/osdu/platform/system/notification + branch: master + tag: latest \ No newline at end of file diff --git a/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/pubsub/EventGridRequestBodyExtractor.java b/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/pubsub/EventGridRequestBodyExtractor.java index c5fcedb7f6693be986329cbfd3527cdc68a57fc2..2452ed32232d38e86c7de8bc89ed9a7a03bf65a2 100644 --- a/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/pubsub/EventGridRequestBodyExtractor.java +++ b/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/pubsub/EventGridRequestBodyExtractor.java @@ -190,4 +190,4 @@ public class EventGridRequestBodyExtractor implements IPubsubRequestBodyExtracto Preconditions.checkNotNull(notificationData.getAttributes().get("correlation-id") , "Request payload parsing error" ); Preconditions.checkNotNull(notificationData.getAttributes().get("data-partition-id") , "Request payload parsing error" ); } -} \ No newline at end of file +} diff --git a/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/provider/azure/EventGridHandshakeHandlerTest.java b/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/pubsub/EventGridHandshakeHandlerTest.java similarity index 99% rename from provider/notification-azure/src/test/java/org/opengroup/osdu/notification/provider/azure/EventGridHandshakeHandlerTest.java rename to provider/notification-azure/src/test/java/org/opengroup/osdu/notification/pubsub/EventGridHandshakeHandlerTest.java index f16dc0061526f54938c74f8549754686e2ececb4..b1cac81ce1b3e57696690b4a3bf989b266f9afc4 100644 --- a/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/provider/azure/EventGridHandshakeHandlerTest.java +++ b/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/pubsub/EventGridHandshakeHandlerTest.java @@ -75,4 +75,4 @@ public class EventGridHandshakeHandlerTest { fail("Should Throw AppException"); } } -} \ No newline at end of file +}