From 5135cce12a4292750ac692b909782933fb4b83fe Mon Sep 17 00:00:00 2001 From: Ahoo Wang Date: Tue, 20 Jun 2023 09:58:18 +0800 Subject: [PATCH] Remove cosky dependency (#174) --- cosec-dependencies/build.gradle.kts | 1 - cosec-gateway-server/build.gradle.kts | 8 +--- .../src/dist/config/bootstrap.yaml | 2 +- .../src/main/resources/bootstrap.yaml | 10 +---- gradle.properties | 2 +- k8s/cosec-gateway-config.yaml | 19 ++++++++ ...teway.yml => cosec-gateway-deployment.yml} | 45 +++---------------- k8s/cosec-gateway-hpa.yaml | 18 ++++++++ k8s/cosec-gateway-service.yaml | 14 ++++++ 9 files changed, 61 insertions(+), 58 deletions(-) create mode 100644 k8s/cosec-gateway-config.yaml rename k8s/{deployment/cosec-gateway.yml => cosec-gateway-deployment.yml} (60%) create mode 100644 k8s/cosec-gateway-hpa.yaml create mode 100644 k8s/cosec-gateway-service.yaml diff --git a/cosec-dependencies/build.gradle.kts b/cosec-dependencies/build.gradle.kts index 9089716..8f179ca 100644 --- a/cosec-dependencies/build.gradle.kts +++ b/cosec-dependencies/build.gradle.kts @@ -16,7 +16,6 @@ dependencies { api(platform("org.springframework.cloud:spring-cloud-dependencies:2022.0.3")) api(platform("me.ahoo.cosid:cosid-bom:2.1.0")) api(platform("me.ahoo.cocache:cocache-bom:2.0.0")) - api(platform("me.ahoo.cosky:cosky-bom:3.3.14")) api(platform("me.zhyd.oauth:JustAuth:1.16.5")) api(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:1.27.0")) constraints { diff --git a/cosec-gateway-server/build.gradle.kts b/cosec-gateway-server/build.gradle.kts index a41b1c8..24a3757 100644 --- a/cosec-gateway-server/build.gradle.kts +++ b/cosec-gateway-server/build.gradle.kts @@ -18,10 +18,8 @@ plugins { kotlin("kapt") } -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) - } +kotlin { + jvmToolchain(17) } tasks.jar.configure { exclude("application.yaml", "bootstrap.yaml") @@ -68,8 +66,6 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-data-redis") implementation("me.ahoo.cosid:cosid-spring-redis") implementation("me.ahoo.cosid:cosid-spring-boot-starter") - implementation("me.ahoo.cosky:spring-cloud-starter-cosky-config") - implementation("me.ahoo.cosky:spring-cloud-starter-cosky-discovery") implementation("org.springframework.cloud:spring-cloud-starter-gateway") implementation("org.springframework.cloud:spring-cloud-starter-openfeign") implementation("org.springframework.cloud:spring-cloud-starter-loadbalancer") diff --git a/cosec-gateway-server/src/dist/config/bootstrap.yaml b/cosec-gateway-server/src/dist/config/bootstrap.yaml index 1a8b882..ea5240c 100644 --- a/cosec-gateway-server/src/dist/config/bootstrap.yaml +++ b/cosec-gateway-server/src/dist/config/bootstrap.yaml @@ -1,3 +1,3 @@ spring: application: - name: ${service.name:cosec-gateway} + name: ${service.name:cosec-gateway} \ No newline at end of file diff --git a/cosec-gateway-server/src/main/resources/bootstrap.yaml b/cosec-gateway-server/src/main/resources/bootstrap.yaml index cf6a2ca..ea5240c 100644 --- a/cosec-gateway-server/src/main/resources/bootstrap.yaml +++ b/cosec-gateway-server/src/main/resources/bootstrap.yaml @@ -1,11 +1,3 @@ spring: application: - name: ${service.name:cosec-gateway} - cloud: - cosky: - namespace: ${cosky.namespace:{dev}} - config: - config-id: ${spring.application.name}.yaml - service-registry: - auto-registration: - enabled: ${cosky.auto-registry:false} + name: ${service.name:cosec-gateway} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index a61e5f5..a41dac3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ # limitations under the License. # group=me.ahoo.cosec -version=2.0.0-M1 +version=2.0.0 description=RBAC-based And Policy-based Multi-Tenant Reactive Security Framework. website=https://github.com/Ahoo-Wang/CoSec issues=https://github.com/Ahoo-Wang/CoSec/issues diff --git a/k8s/cosec-gateway-config.yaml b/k8s/cosec-gateway-config.yaml new file mode 100644 index 0000000..8e9c63d --- /dev/null +++ b/k8s/cosec-gateway-config.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: cosec-gateway-config + labels: + app: cosec-gateway-config +data: + bootstrap.yaml: |- + spring: + application: + name: ${service.name:cosec-gateway} + application.yaml: |- + server: + error: + whitelabel: + enabled: false + cosec: + authentication: + enabled: false \ No newline at end of file diff --git a/k8s/deployment/cosec-gateway.yml b/k8s/cosec-gateway-deployment.yml similarity index 60% rename from k8s/deployment/cosec-gateway.yml rename to k8s/cosec-gateway-deployment.yml index a368797..f8fec12 100644 --- a/k8s/deployment/cosec-gateway.yml +++ b/k8s/cosec-gateway-deployment.yml @@ -16,12 +16,6 @@ spec: spec: containers: - env: - - name: SPRING_REDIS_HOST - value: redis-uri:6379 - - name: SPRING_REDIS_PASSWORD - value: redis-pwd - - name: SPRING_CLOUD_COSKY_NAMESPACE - value: '{dev}' - name: TZ value: Asia/Shanghai image: ahoowang/cosec-gateway:lastVersion @@ -52,42 +46,13 @@ spec: volumeMounts: - mountPath: /etc/localtime name: volume-localtime + - mountPath: /opt/cosec-gateway-server/config/ + name: cosec-gateway-config volumes: - hostPath: path: /etc/localtime type: "" name: volume-localtime ---- -apiVersion: v1 -kind: Service -metadata: - name: cosec-gateway - labels: - app: cosec-gateway -spec: - selector: - app: cosec-gateway - ports: - - name: http - port: 80 - protocol: TCP - targetPort: 8080 ---- -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: cosec-gateway-hpa -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: cosec-gateway - minReplicas: 2 - maxReplicas: 10 - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: 600 \ No newline at end of file + - configMap: + name: cosec-gateway-config + name: cosec-gateway-config \ No newline at end of file diff --git a/k8s/cosec-gateway-hpa.yaml b/k8s/cosec-gateway-hpa.yaml new file mode 100644 index 0000000..0d959b2 --- /dev/null +++ b/k8s/cosec-gateway-hpa.yaml @@ -0,0 +1,18 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: cosec-gateway-hpa +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: cosec-gateway + minReplicas: 2 + maxReplicas: 10 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 600 diff --git a/k8s/cosec-gateway-service.yaml b/k8s/cosec-gateway-service.yaml new file mode 100644 index 0000000..d761de5 --- /dev/null +++ b/k8s/cosec-gateway-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: cosec-gateway + labels: + app: cosec-gateway +spec: + selector: + app: cosec-gateway + ports: + - name: http + port: 80 + protocol: TCP + targetPort: 8080 \ No newline at end of file