Prechádzať zdrojové kódy

feat(compose): update whoami template from release/v0.1.0

xcad 6 mesiacov pred
rodič
commit
3c13c4a187

+ 38 - 28
library/compose/whoami/compose.yaml.j2

@@ -1,41 +1,51 @@
 services:
-  {{ service_name | default('whoami') }}:
-    image: traefik/whoami
-    container_name: {{ container_name | default('whoami') }}
+  {{ service_name }}:
+    image: traefik/whoami:v1.11.0
+    {% if not swarm_enabled %}
+    container_name: {{ container_name }}
+    restart: {{ restart_policy }}
+    {% endif %}
+    hostname: {{ container_hostname }}
     {% if swarm_enabled %}
     deploy:
-      replicas: {{ swarm_replicas | default(1) }}
+      mode: {{ swarm_placement_mode }}
+      {% if swarm_placement_mode == "replicated" %}
+      replicas: {{ swarm_replicas }}
+      {% endif %}
+      {% if swarm_placement_host %}
+      placement:
+        constraints:
+          - node.hostname == {{ swarm_placement_host }}
+      {% endif %}
       restart_policy:
         condition: on-failure
-    {% endif %}
-    {% if ports_enabled %}
-    ports:
-      - "{{ ports_http | default(8080) }}:80"
-      - "{{ ports_https | default(8443) }}:443"
-    {% endif %}
-    {% if network_enabled %}
-    networks:
-      - {{ network_name | default("bridge") }}
-    {% endif %}
-    {% if traefik_enabled %}
+      labels:
+        - traefik.enable=true
+        - traefik.http.services.{{ service_name }}.loadbalancer.server.port=80
+        - traefik.http.routers.{{ service_name }}-http.rule=Host(`{{ traefik_host }}`)
+        - traefik.http.routers.{{ service_name }}-http.entrypoints={{ traefik_entrypoint }}
+        {% if traefik_tls_enabled %}
+        - traefik.http.routers.{{ service_name }}-https.rule=Host(`{{ traefik_host }}`)
+        - traefik.http.routers.{{ service_name }}-https.entrypoints={{ traefik_tls_entrypoint }}
+        - traefik.http.routers.{{ service_name }}-https.tls=true
+        - traefik.http.routers.{{ service_name }}-https.tls.certresolver={{ traefik_tls_certresolver }}
+        {% endif %}
+    {% else %}
     labels:
       - traefik.enable=true
-      - traefik.http.services.{{ service_name | default("whoami") }}.loadbalancer.server.port=80
-      - traefik.http.routers.{{ service_name | default("whoami") }}-http.rule=Host(`{{ traefik_host }}`)
-      - traefik.http.routers.{{ service_name | default("whoami") }}-http.entrypoints={{ traefik_entrypoint | default("web") }}
+      - traefik.http.services.{{ service_name }}.loadbalancer.server.port=80
+      - traefik.http.routers.{{ service_name }}-http.rule=Host(`{{ traefik_host }}`)
+      - traefik.http.routers.{{ service_name }}-http.entrypoints={{ traefik_entrypoint }}
       {% if traefik_tls_enabled %}
-      - traefik.http.routers.{{ service_name | default("whoami") }}-https.rule=Host(`{{ traefik_host }}`)
-      - traefik.http.routers.{{ service_name | default("whoami") }}-https.entrypoints={{ traefik_tls_entrypoint | default("websecure") }}
-      - traefik.http.routers.{{ service_name | default("whoami") }}-https.tls=true
-      - traefik.http.routers.{{ service_name | default("whoami") }}-https.tls.certresolver={{ traefik_tls_certresolver }}
+      - traefik.http.routers.{{ service_name }}-https.rule=Host(`{{ traefik_host }}`)
+      - traefik.http.routers.{{ service_name }}-https.entrypoints={{ traefik_tls_entrypoint }}
+      - traefik.http.routers.{{ service_name }}-https.tls=true
+      - traefik.http.routers.{{ service_name }}-https.tls.certresolver={{ traefik_tls_certresolver }}
       {% endif %}
     {% endif %}
-    restart: {{ restart_policy | default("unless-stopped") }}
+    networks:
+      - {{ traefik_network }}
 
-{% if network_enabled %}
 networks:
-  {{ network_name | default("bridge") }}:
-    {% if network_external %}
+  {{ traefik_network }}:
     external: true
-    {% endif %}
-{% endif %}

+ 49 - 29
library/compose/whoami/template.yaml

@@ -1,38 +1,58 @@
 ---
 kind: compose
+schema: "1.1"
 metadata:
   name: Whoami
-  description: >
-    Whoami is a simple web application that displays information about the HTTP request it receives.
-    It is often used for testing and debugging purposes to verify that a web server or reverse proxy is functioning correctly.
-
-
-    Project: https://github.com/traefik/whoami
-
-    Documentation: https://traefik.io/docs/
-
-    GitHub: https://github.com/traefik/whoami
-  version: 0.1.0
+  description: |
+    A **simple web application** that displays information about the HTTP request it receives.
+    ## Use Cases
+    - Testing reverse proxy configurations
+    - Debugging web server setups
+    - Verifying load balancer functionality
+    - Quick HTTP endpoint testing
+    ## Resources
+    - **Project**: https://github.com/traefik/whoami
+    - **Documentation**: https://traefik.io/docs/
+    - **GitHub**: https://github.com/traefik/whoami
+  next_steps: |
+    ## Post-Installation Steps
+    1. **Start the service**:
+       ```bash
+       docker compose up -d
+       ```
+    2. **Verify the service is running**:
+       ```bash
+       docker compose ps
+       ```
+    3. **Test the endpoint**:
+       - Visit the configured host in your browser
+       - Or use curl: `curl http://{{ traefik_host }}`
+    4. **Check Traefik dashboard** (if enabled):
+       - Verify the route is registered correctly
+       - Check middleware configuration
+  version: 1.11.0
   author: Christian Lempa
-  date: '2025-09-28'
+  date: '2025-10-30'
   tags:
-    - reverse-proxy
-    - testing
-  draft: true
+    - traefik
+    - swarm
+  draft: false
 spec:
-  ports:
-    vars:
-      ports_http:
-        description: "Host port for HTTP (80)"
-        type: int
-        default: 80
-      ports_https:
-        description: "Host port for HTTPS (443)"
-        type: int
-        default: 443
   general:
     vars:
-      whoami_version:
-        type: str
-        description: Whoami version
-        default: latest
+      service_name:
+        default: whoami
+      container_name:
+        default: whoami
+      container_hostname:
+        default: whoami
+  traefik:
+    required: true
+    needs: []
+    vars:
+      traefik_host:
+        default: whoami.localhost
+  traefik_tls:
+    needs: []
+  swarm:
+    needs: []