-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HPA example. Lint and check adjustments
- Loading branch information
Showing
9 changed files
with
1,762 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: v2 | ||
appVersion: '1.0' | ||
description: Basic example with Horizontal Pod Autoscaling applied to WMS instances in geoserver-cloud using pgconfig as catalog persistence component | ||
name: gs-cloud-hpa | ||
version: 0.1.0 | ||
dependencies: | ||
- name: geoservercloud | ||
repository: file://../../ | ||
version: 0.1.0 | ||
# Postgres dependency used for pgconfig database | ||
# Note: bitnami postgres chart is updated at initialization to add Postgis extension | ||
- name: 'postgresql' | ||
version: 14.0.0 | ||
repository: 'https://charts.bitnami.com/bitnami' | ||
condition: postgresql.enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# HPA example | ||
|
||
This example allows to create a very simple GeoserverCloud deployment in your local cluster, which allows to evaluate and understand how Horizontal Pod Autoscaling (HPA) works. | ||
|
||
The setup includes: | ||
|
||
- a unique WebUI instance, (to allow see catalog configuration) | ||
- the gateway, (access to the GeoserverCloud solution) | ||
- 2 WMS instances, (the initial 2 instances which serve the WMS OGC protocol) | ||
- a REST API instance, (used by attached script that allows to create a minimal catalog for testing) | ||
- a local Postgres and (used along with PgConfig profile, since we want to minimize startup time, so we focus on reducing catalog reading) | ||
- RabbitMQ (the bus event communication across instances) | ||
|
||
Following steps mentioned in next section you will be able to see how HPA works automatically (up to 100 containers created!), when the cluster is stressed by the attached script defined for that. | ||
|
||
# Considerations | ||
|
||
- Read documentation in ../README.md file (since for running this demo, it's required to have a local cluster installed, along with kubectl) | ||
- Execution of this kind of tests could freeze your machine, if your hardware/setup is not adequate. | ||
- If in doubt, change values in the HPA section on the values.yaml file, so you can determine which is the value for maxReplicas (by default = 100) | ||
|
||
# Steps | ||
|
||
At repository base folder level, follow next steps: | ||
|
||
1. Execute | ||
|
||
```shell | ||
make example-wms-hpa | ||
``` | ||
|
||
2. Use | ||
|
||
```shell | ||
kubectl get po | ||
``` | ||
|
||
in order to check that all the pods are up and running (that is, all of them with values STATUS = Running and READY = 1/1) | ||
ie. | ||
|
||
```shell | ||
NAME READY STATUS RESTARTS AGE | ||
gs-cloud-pgconfig-wms-hpa-gsc-gateway-76b46b9c7f-gs976 1/1 Running 0 12m | ||
gs-cloud-pgconfig-wms-hpa-postgresql-0 1/1 Running 0 12m | ||
gs-cloud-pgconfig-wms-hpa-gsc-rest-7fdbcf799f-qshn5 1/1 Running 0 12m | ||
gs-cloud-pgconfig-wms-hpa-gsc-webui-6cf8f88695-646xt 1/1 Running 0 12m | ||
gs-cloud-common-rabbitmq-0 1/1 Running 0 12m | ||
gs-cloud-pgconfig-wms-hpa-gsc-wms-758dfd8765-qs946 1/1 Running 0 11m | ||
gs-cloud-pgconfig-wms-hpa-gsc-wms-758dfd8765-pth59 1/1 Running 0 10m | ||
``` | ||
|
||
3. Define a DNS alias (used in scripts to avoid local references. Note: you can edit scripts if you prefer) | ||
|
||
```shell | ||
kubectl get ingress --no-headers gs-cloud-pgconfig-wm-geoserver-host1 | awk '{printf("%s\t%s\n",$4,$3 )}' | sudo tee -a /etc/hosts | ||
``` | ||
|
||
3. Execute | ||
|
||
```shell | ||
./examples/pgconfig-wms-hpa/init-catalog.sh | ||
``` | ||
|
||
4. Execute | ||
|
||
```shell | ||
watch kubectl get po | ||
``` | ||
|
||
in order to see list of pods (and watch every 2 secs) | ||
|
||
5. In a different console, execute | ||
|
||
```shell | ||
./examples/pgconfig-wms-hpa/stress-server.sh | ||
``` | ||
|
||
so you will trigger 1000 simultaneous request to the cluster. | ||
|
||
At this point you will be able to see (in console 1) how the list of pods are increased and decreased during execution of the stress-server.sh script. | ||
|
||
6. Execute | ||
|
||
```shell | ||
make examples-clean | ||
``` | ||
|
||
so you get your environment clean, and deployment down. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
GEOSERVER_URL="http://gscloud.local/geoserver-cloud" | ||
USER="admin" | ||
PASSWORD="geoserver" | ||
|
||
WORKSPACE="hpa-test" | ||
DATASTORE="swisstopo_wms" | ||
WMS_URL="https://wms.geo.admin.ch/?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities" | ||
LAYER_NAME="ch.bafu.grundwasserkoerper" | ||
|
||
echo -e "\n------------------------------------" | ||
echo -e "Preparing initialization process ..." | ||
curl -u $USER:$PASSWORD -X DELETE "$GEOSERVER_URL/rest/workspaces/$WORKSPACE?recurse=true" | ||
|
||
echo -e "------------------------------------" | ||
echo -e "Creating workspace '$WORKSPACE'..." | ||
if ! curl -u $USER:$PASSWORD -X POST -H "Content-Type: text/xml" -d "<workspace><name>$WORKSPACE</name></workspace>" $GEOSERVER_URL/rest/workspaces --fail; then | ||
echo -e "Error creating workspace\n" | ||
exit 1 | ||
fi | ||
|
||
echo -e "\n------------------------------------" | ||
echo -e "Creating WMS datastore '$DATASTORE'..." | ||
if ! curl -u $USER:$PASSWORD -X POST -H "Content-Type: text/xml" -d "<wmsStore><type>WMS</type><name>$DATASTORE</name><workspace>$WORKSPACE</workspace><capabilitiesURL>$WMS_URL</capabilitiesURL><enabled>true</enabled></wmsStore>" $GEOSERVER_URL/rest/workspaces/$WORKSPACE/wmsstores --fail; then | ||
echo -e "\nError creating datastore" | ||
exit 1 | ||
fi | ||
|
||
echo -e "\n------------------------------------" | ||
echo -e "Publishing layer '$LAYER_NAME' from datastore '$DATASTORE'..." | ||
if ! curl -u $USER:$PASSWORD -X POST -H "Content-Type: text/xml" -d "<wmsLayer><name>$LAYER_NAME</name><defaultStyle><name>raster</name></defaultStyle></wmsLayer>" $GEOSERVER_URL/rest/workspaces/$WORKSPACE/wmsstores/$DATASTORE/wmslayers --fail; then | ||
echo -e "Error publishing layer\n" | ||
exit 1 | ||
fi | ||
|
||
echo -e "\n------------------------------------" | ||
echo -e "Catalog initialized successfully.\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
WMS_URL="http://gscloud.local/geoserver-cloud/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&STYLES&LAYERS=hpa-test%3Ach.bafu.grundwasserkoerper&exceptions=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A2056&WIDTH=769&HEIGHT=359&BBOX=2628297.2396917907%2C1161127.5666655225%2C2745623.985655881%2C1215846.1146757442" | ||
|
||
for _ in {1..1000} | ||
do | ||
curl -s "$WMS_URL" > /dev/null & | ||
done | ||
|
||
wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
postgresql: | ||
enabled: true | ||
global: | ||
postgresql: | ||
auth: | ||
# this should be replaced by your existing secret | ||
# existingSecret: your-secret-name | ||
postgresPassword: g30s3rv3r | ||
|
||
additionalVolumes: &additional-volumes | ||
cache: | ||
emptyDir: {} | ||
|
||
additionalVolumeMounts: &additional-volume-mounts | ||
/mnt/cache: | ||
name: 'cache' | ||
|
||
env: &env-override | ||
PG_PASSWORD: | ||
type: secret | ||
name: 'gs-cloud-pgconfig-wms-hpa-postgresql' | ||
key: 'postgres-password' | ||
RABBITMQ_HOST: | ||
value: 'gs-cloud-common-rabbitmq' | ||
RABBITMQ_USER: | ||
value: 'geoserver' | ||
RABBITMQ_PASSWORD: | ||
type: secret | ||
name: 'gs-cloud-common-rabbitmq' | ||
key: 'rabbitmq-password' | ||
SPRING_PROFILES_ACTIVE: | ||
value: standalone,pgconfig | ||
GEOWEBCACHE_CACHE_DIR: | ||
value: '/mnt/cache' | ||
JAVA_OPTS: | ||
value: '$(JAVA_OPTS_DEFAULT) -XshowSettings:system' | ||
PGCONFIG_HOST: | ||
value: gs-cloud-pgconfig-wms-hpa-postgresql-hl | ||
PGCONFIG_PORT: | ||
value: '5432' | ||
PGCONFIG_DATABASE: | ||
value: postgres | ||
PGCONFIG_SCHEMA: | ||
value: pgconfig | ||
PGCONFIG_USERNAME: | ||
value: postgres | ||
PGCONFIG_PASSWORD: | ||
type: secret | ||
name: 'gs-cloud-pgconfig-wms-hpa-postgresql' | ||
key: 'postgres-password' | ||
PGCONFIG_MAXCONNECTIONS: | ||
value: '10' | ||
|
||
additional-stuff: &additional-stuff | ||
volumes: | ||
<<: *additional-volumes | ||
containers: | ||
spring: | ||
env: | ||
<<: *env-override | ||
volumeMounts: | ||
<<: *additional-volume-mounts | ||
|
||
geoservercloud: | ||
global: | ||
profile: standalone,pgconfig | ||
image: | ||
pullPolicy: IfNotPresent | ||
geoserver: | ||
ingress: | ||
enabled: true | ||
hostGroups: | ||
host1: | ||
tls: | ||
enabled: false | ||
hosts: | ||
- gscloud.local | ||
services: | ||
gateway: | ||
ingress: | ||
enabled: true | ||
<<: *additional-stuff | ||
webui: | ||
<<: *additional-stuff | ||
wms: | ||
replicaCount: 2 | ||
hpa: | ||
enabled: true | ||
minReplicas: 2 | ||
maxReplicas: 100 | ||
metrics: | ||
- type: Resource | ||
resource: | ||
name: cpu | ||
target: | ||
type: Utilization | ||
averageUtilization: 50 | ||
<<: *additional-stuff | ||
rest: | ||
replicaCount: 1 | ||
<<: *additional-stuff | ||
wcs: | ||
enabled: false | ||
replicaCount: 0 | ||
<<: *additional-stuff | ||
wfs: | ||
enabled: false | ||
replicaCount: 0 | ||
<<: *additional-stuff | ||
gwc: | ||
enabled: false | ||
replicaCount: 0 | ||
<<: *additional-stuff | ||
wps: | ||
enabled: false | ||
replicaCount: 0 | ||
<<: *additional-stuff | ||
acl: | ||
enabled: false |
Oops, something went wrong.