From 6ac34492232540e83bbe195016c1d1e163387b14 Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 9 May 2024 21:34:43 -0300 Subject: [PATCH] subir a aplicacao azure gateway --- kubernetes/azure/metrics.yaml | 188 ------------------ kubernetes/azure/tiulanches-configmap.yaml | 12 ++ ...oyment.yaml => tiulanches-deployment.yaml} | 34 ++-- kubernetes/local/startapp.sh | 9 +- kubernetes/local/tiulanches-deployment.yaml | 49 +++-- 5 files changed, 59 insertions(+), 233 deletions(-) delete mode 100644 kubernetes/azure/metrics.yaml create mode 100644 kubernetes/azure/tiulanches-configmap.yaml rename kubernetes/azure/{app-deployment.yaml => tiulanches-deployment.yaml} (70%) diff --git a/kubernetes/azure/metrics.yaml b/kubernetes/azure/metrics.yaml deleted file mode 100644 index f6da3e4..0000000 --- a/kubernetes/azure/metrics.yaml +++ /dev/null @@ -1,188 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - labels: - k8s-app: metrics-server - name: metrics-server - namespace: kube-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - k8s-app: metrics-server - rbac.authorization.k8s.io/aggregate-to-admin: "true" - rbac.authorization.k8s.io/aggregate-to-edit: "true" - rbac.authorization.k8s.io/aggregate-to-view: "true" - name: system:aggregated-metrics-reader -rules: -- apiGroups: - - metrics.k8s.io - resources: - - pods - - nodes - verbs: - - get - - list - - watch ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - k8s-app: metrics-server - name: system:metrics-server -rules: -- apiGroups: - - "" - resources: - - pods - - nodes - - nodes/stats - - namespaces - - configmaps - verbs: - - get - - list - - watch ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - labels: - k8s-app: metrics-server - name: metrics-server-auth-reader - namespace: kube-system -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: extension-apiserver-authentication-reader -subjects: -- kind: ServiceAccount - name: metrics-server - namespace: kube-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - k8s-app: metrics-server - name: metrics-server:system:auth-delegator -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: system:auth-delegator -subjects: -- kind: ServiceAccount - name: metrics-server - namespace: kube-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - k8s-app: metrics-server - name: system:metrics-server -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: system:metrics-server -subjects: -- kind: ServiceAccount - name: metrics-server - namespace: kube-system ---- -apiVersion: v1 -kind: Service -metadata: - labels: - k8s-app: metrics-server - name: metrics-server - namespace: kube-system -spec: - ports: - - name: https - port: 443 - protocol: TCP - targetPort: https - selector: - k8s-app: metrics-server ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - k8s-app: metrics-server - name: metrics-server - namespace: kube-system -spec: - selector: - matchLabels: - k8s-app: metrics-server - strategy: - rollingUpdate: - maxUnavailable: 0 - template: - metadata: - labels: - k8s-app: metrics-server - spec: - containers: - - args: - - --cert-dir=/tmp - - --secure-port=4443 - - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname - - --kubelet-use-node-status-port - - --kubelet-insecure-tls - image: k8s.gcr.io/metrics-server/metrics-server:v0.4.2 - imagePullPolicy: IfNotPresent - livenessProbe: - failureThreshold: 3 - httpGet: - path: /livez - port: https - scheme: HTTPS - periodSeconds: 10 - name: metrics-server - ports: - - containerPort: 4443 - name: https - protocol: TCP - readinessProbe: - failureThreshold: 3 - httpGet: - path: /readyz - port: https - scheme: HTTPS - periodSeconds: 10 - securityContext: - readOnlyRootFilesystem: true - runAsNonRoot: true - runAsUser: 1000 - volumeMounts: - - mountPath: /tmp - name: tmp-dir - nodeSelector: - kubernetes.io/os: linux - priorityClassName: system-cluster-critical - serviceAccountName: metrics-server - volumes: - - emptyDir: {} - name: tmp-dir ---- -apiVersion: apiregistration.k8s.io/v1 -kind: APIService -metadata: - labels: - k8s-app: metrics-server - name: v1beta1.metrics.k8s.io -spec: - group: metrics.k8s.io - groupPriorityMinimum: 100 - insecureSkipTLSVerify: true - service: - name: metrics-server - namespace: kube-system - version: v1beta1 - versionPriority: 100 - \ No newline at end of file diff --git a/kubernetes/azure/tiulanches-configmap.yaml b/kubernetes/azure/tiulanches-configmap.yaml new file mode 100644 index 0000000..680f40c --- /dev/null +++ b/kubernetes/azure/tiulanches-configmap.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: tiulanches-config + labels: + app: tiulanches-config +data: + ds_url: jdbc:mysql://tiulanchessrv.mysql.database.azure.com:3306/tiulanches?createDatabaseIfNotExist=true&useSSL=true&requireSSL=false + ds_pass: V$!d4rmysql + ds_username: tiulanches@tiulanchessrv + conexao_kafka: 10.0.132.224:9092 + \ No newline at end of file diff --git a/kubernetes/azure/app-deployment.yaml b/kubernetes/azure/tiulanches-deployment.yaml similarity index 70% rename from kubernetes/azure/app-deployment.yaml rename to kubernetes/azure/tiulanches-deployment.yaml index 32a25e8..3f964f9 100644 --- a/kubernetes/azure/app-deployment.yaml +++ b/kubernetes/azure/tiulanches-deployment.yaml @@ -1,18 +1,18 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: app-deployment + name: tiulanches-deployment labels: - app: app-deployment + app: tiulanches-deployment spec: selector: matchLabels: - app: app + app: tiulanches replicas: 1 template: metadata: labels: - app: app + app: tiulanches spec: containers: - name: tiulanches @@ -26,39 +26,39 @@ spec: cpu: "1.0" ports: - containerPort: 8080 - name: app-port + name: tiulanches-port env: - name: DATASOURCE_URL valueFrom : configMapKeyRef: - name: app-config + name: tiulanches-config key: ds_url - name: DATASOURCE_PASSWORD valueFrom: configMapKeyRef: - name: app-config + name: tiulanches-config key: ds_pass - name: DATASOURCE_USERNAME valueFrom: configMapKeyRef: - name: app-config + name: tiulanches-config key: ds_username - - name: ACCESS_TOKEN_MP - valueFrom: - configMapKeyRef: - name: app-config - key: mp_token + - name: CONEXAO_KAFKA + valueFrom : + configMapKeyRef : + name : tiulanches-config + key : conexao_kafka readinessProbe: httpGet: path: /actuator/health - port: app-port + port: tiulanches-port initialDelaySeconds: 60 periodSeconds: 10 failureThreshold: 3 livenessProbe: httpGet: path: /actuator/health - port: app-port + port: tiulanches-port initialDelaySeconds: 60 periodSeconds: 10 failureThreshold: 3 @@ -66,10 +66,10 @@ spec: apiVersion: v1 kind: Service metadata: - name: app-svc + name: tiulanches-svc spec: selector: - app: app + app: tiulanches ports: - port: 8080 targetPort: 8080 diff --git a/kubernetes/local/startapp.sh b/kubernetes/local/startapp.sh index 775228d..77db59a 100755 --- a/kubernetes/local/startapp.sh +++ b/kubernetes/local/startapp.sh @@ -11,12 +11,5 @@ sleep 60 echo 'Subindo aplicação...' kubectl apply -f tiulanches-deployment.yaml -https=http://localhost:31200/actuator/health -status=0 -while [ $status -eq 0 ] -do - sleep 5 - status=`curl $https -k -s -f -o /dev/null && echo 1 || echo 0` -done - +sleep 60 echo 'Aplicação pronta, divirta-se ;)' \ No newline at end of file diff --git a/kubernetes/local/tiulanches-deployment.yaml b/kubernetes/local/tiulanches-deployment.yaml index 3994882..cc7dbbe 100644 --- a/kubernetes/local/tiulanches-deployment.yaml +++ b/kubernetes/local/tiulanches-deployment.yaml @@ -7,7 +7,7 @@ metadata: data: ds_url: jdbc:mysql://mysql-svc/tiulanches?&createDatabaseIfNotExist=true ds_username: root - conexao_kafka: 10.105.69.241:9092 + conexao_kafka: 10.110.5.216:9092 --- apiVersion: apps/v1 kind: Deployment @@ -66,20 +66,6 @@ spec: configMapKeyRef : name : db-config key : ds_username - readinessProbe: - httpGet: - path: /actuator/health - port: tiulanches-port - initialDelaySeconds: 60 - periodSeconds: 10 - failureThreshold: 3 - livenessProbe: - httpGet: - path: /actuator/health - port: tiulanches-port - initialDelaySeconds: 60 - periodSeconds: 10 - failureThreshold: 3 --- apiVersion: v1 kind: Service @@ -89,8 +75,31 @@ spec: selector: app: tiulanches ports: - - protocol: TCP - port: 8080 - nodePort: 31200 - type: NodePort - \ No newline at end of file + - port: 80 + targetPort: 8080 + protocol: TCP + name: http +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: tiulanches-ingress +spec: + ingressClassName: nginx + rules: + - http: + paths: + - pathType: Prefix + path: /produtos + backend: + service: + name: tiulanches-svc + port: + number: 80 + - pathType: Prefix + path: /clientes + backend: + service: + name: tiulanches-svc + port: + number: 80