writing-skills
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
geoserver-cloudUse when deploying GeoServer on Kubernetes as cloud-native microservices with auto-scaling, service discovery, and centralized configuration. GeoServer Cloud: break monolithic GeoServer into independently scalable WMS/WFS/WCS services.
Independent GitHub snapshot · Automated classification · Original documentation governs
name: geoserver-cloud description: "Use when deploying GeoServer on Kubernetes as cloud-native microservices with auto-scaling, service discovery, and centralized configuration. GeoServer Cloud: break monolithic GeoServer into independently scalable WMS/WFS/WCS services." tags:
项目地址: https://github.com/geoserver/geoserver-cloud
官方文档: https://geoserver.org/geoserver-cloud/
Docker Hub: https://hub.docker.com/u/geoservercloud(镜像标签与 GeoServer 主版本对应,如
3.0.0)许可证: GPL-2.0
GeoServer Cloud(GS Cloud):
GEOSERVER_BUS_ENABLED)/geoserver/cloud(网关 http://localhost:9090/geoserver/cloud/...)| 服务 | 镜像 | 用途 |
|---|---|---|
gateway | geoservercloud/geoserver-cloud-gateway | 网关 |
discovery | geoservercloud/geoserver-cloud-discovery | 服务发现(3.x 的官方 compose 改用 hashicorp/consul) |
config | geoservercloud/geoserver-cloud-config | 配置中心 |
web-ui | geoservercloud/geoserver-cloud-webui | 管理界面 |
rest | geoservercloud/geoserver-cloud-rest | REST API |
wms | geoservercloud/geoserver-cloud-wms | WMS |
wfs | geoservercloud/geoserver-cloud-wfs | WFS |
wcs | geoservercloud/geoserver-cloud-wcs | WCS |
wps | geoservercloud/geoserver-cloud-wps | WPS |
gwc | geoservercloud/geoserver-cloud-gwc | 瓦片缓存 |
# 官方 Quick Start:下载稳定版 compose 文件(仓库内的 compose/ 目录仅供开发调试)
wget "https://geoserver.org/geoserver-cloud/deploy/docker-compose/stable/pgconfig/compose.yml"
docker compose pull
docker compose up -d
docker compose ps
# Gateway: http://localhost:9090/geoserver/cloud (Web UI)
# Consul : http://localhost:8500 (服务发现与控制台)
curl -u admin:geoserver "http://localhost:9090/geoserver/cloud/rest/workspaces.json"
| 后端 | 适用场景 |
|---|---|
| datadir | 共享卷(NFS/PVC),简单 |
| pgconfig | 生产推荐,强一致 |
| jdbcconfig | 旧方案,已被替代 |
启用 PgConfig:
SPRING_PROFILES_ACTIVE: "pgconfig" # 启用 PgConfig 后端
PGCONFIG_HOST: "geoserverdb"
PGCONFIG_PORT: "5432"
PGCONFIG_DATABASE: "geoserver"
PGCONFIG_USERNAME: "geoserver"
PGCONFIG_PASSWORD: "geoserver"
PGCONFIG_SCHEMA: "pgconfig" # 启动时自动创建 schema
注意: 走 Spring Cloud Config Server 集中下发时,以上变量加前缀 SPRING_CLOUD_CONFIG_SERVER_OVERRIDES_(如 SPRING_CLOUD_CONFIG_SERVER_OVERRIDES_PGCONFIG_HOST)配在 config 服务上;standalone profile(Kubernetes 常用)则直接写在各服务上。
# Chart:camptocamp/helm-geoserver-cloud(chart 名 geoservercloud,最新 3.0.1)
helm repo add geoserver-cloud https://camptocamp.github.io/helm-geoserver-cloud
helm repo update
官方要求把该 chart 作为**子 chart(依赖)**引入自己的 umbrella chart(不直接
helm install),副本数等参数写在子 chart 键geoservercloud下:# Chart.yaml dependencies: - name: geoservercloud repository: https://camptocamp.github.io/helm-geoserver-cloud version: 3.0.1# values.yaml geoservercloud: global: profile: standalone,pgconfig geoserver: services: wms: replicaCount: 3helm dependency update && helm install my-gsc . -n gis --create-namespace -f values.yaml # 临时扩缩容也可直接改 Deployment(chart 默认 nameOverride 为 gsc) kubectl -n gis get deploy | grep wms
| 路径 | 转发到 |
|---|---|
/geoserver/cloud/wms | wms |
/geoserver/cloud/wfs | wfs |
/geoserver/cloud/wcs | wcs |
/geoserver/cloud/wps | wps |
/geoserver/cloud/gwc | gwc |
/geoserver/cloud/rest | rest |
/geoserver/cloud/web | web-ui |
前缀由 GEOSERVER_BASE_PATH(默认 compose 中为 /geoserver/cloud)控制,网关的 StripBasePath 过滤器去掉前缀后再转发(/geoserver/cloud/wms → 下游 /wms)。
任意修改 → REST/web-ui 发送 RemoteApplicationEvent 到 RabbitMQ → 所有副本订阅刷新本地 Catalog,秒级一致。
# 环境变量形式(compose 中使用)
GEOSERVER_BUS_ENABLED: "true"
RABBITMQ_HOST: rabbitmq
RABBITMQ_PORT: "5672"
management:
endpoints.web.exposure.include: "*"
metrics.export.prometheus.enabled: true
/actuator/prometheus(Micrometer 指标,另有 /actuator/metrics)直接挂载现有 GeoServer 数据目录平滑迁移:
docker run -e SPRING_PROFILES_ACTIVE=datadir \
-v /mnt/gsdata:/opt/app/data_directory \
geoservercloud/geoserver-cloud-wms:3.0.0
delivery_limit 避免风暴| 问题 | 解决 |
|---|---|
| 配置不同步 | 检查 RabbitMQ 可达 + GEOSERVER_BUS_ENABLED=true |
| Web UI 改了 wms 没生效 | 检查事件订阅 |
| 启动顺序错乱 | depends_on + 健康检查;K8s 用 initContainers |
| OOM | 调整 -Xmx,按服务独立资源 |
# 下载稳定版 pgconfig compose(仓库内 compose/ 目录仅供开发调试)
wget "https://geoserver.org/geoserver-cloud/deploy/docker-compose/stable/pgconfig/compose.yml"
# 启动基础设施 + 所有微服务
docker compose pull
docker compose up -d
# 验证 Gateway 可访问
curl -u admin:geoserver http://localhost:9090/geoserver/cloud/rest/about/version.json
# 扩容 WMS 服务(3 副本)
docker compose up -d --scale wms=3
# 添加 Helm 仓库(chart 名 geoservercloud,由 camptocamp 维护)
helm repo add geoserver-cloud https://camptocamp.github.io/helm-geoserver-cloud
helm repo update
# 在自己的 umbrella chart 中把 geoservercloud 声明为依赖(RabbitMQ/PostgreSQL 同样以依赖引入)
# values.yaml 里写 geoservercloud.geoserver.services.wms.replicaCount 等参数
helm dependency update
helm upgrade --install gs . -n gis --create-namespace -f values.yaml
# 手动伸缩 WMS(先查出 Deployment 名)
kubectl -n gis get deploy | grep wms
kubectl -n gis scale deploy <wms-deployment> --replicas=10
localhost:9090/geoserver/cloud) 访问 Web UIGEOSERVER_BUS_ENABLED=true 且 RabbitMQ 可达GEOSERVER_BASE_PATH=/geoserver/cloud,构造服务 URL 时不要漏掉-Xmx,避免 OOM