使用带有自定义配置和样式文件的 Kubernetes for TileServer-GL

Posted

技术标签:

【中文标题】使用带有自定义配置和样式文件的 Kubernetes for TileServer-GL【英文标题】:Using Kubernetes for TileServer-GL with custom config and style files 【发布时间】:2020-07-21 10:29:06 【问题描述】:

如何使用 Kubernetes 向 tileserver-gl 添加自定义 config.json 和自定义样式 /styles/custom.json?到目前为止,这是我的 kubernetes 清单文件。 Tileserver-gl 启动并运行良好,但我没有看到我定义的自定义主题。看起来我的自定义 config.json 文件没有被应用。使用configMapvolumeMounts 是正确的方法吗?

apiVersion: apps/v1
kind: Deployment
metadata:
  name: map-tile-server
  namespace: test
  labels:
    app: map-tile-server
spec:
  replicas: 1
  selector:
    matchLabels:
      app: map-tile-server
  template:
    metadata:
      namespace: test
      labels:
        app: map-tile-server
    spec:
      containers:
        - name: map-tile-server
          image: klokantech/tileserver-gl:v2.6.0          
          ports:
            - containerPort: 8080
              name: http
          volumeMounts:
            - name: "map-tile-server-config"
              mountPath: "/config.json"
            - name: "map-tile-server-style-config"
              mountPath: "/styles/custom.json"
          resources:
            limits:
              memory: "256Mi"
              cpu: "1"
      volumes:
        - name: "map-tile-server-config"
          configMap:
            name: "map-tile-server-config"
        - name: "map-tile-server-style-config"
          configMap:
            name: "map-tile-server-style-config"
---
apiVersion: v1
kind: ConfigMap
data:
  config.json: " \"options\":  \"paths\":  \"root\": \"\", \"fonts\": \"\", \"styles\": \"styles\", \"mbtiles\": \"data\" , \"serveStaticMaps\": true, \"formatQuality\":  \"jpeg\": 90, \"webp\": 90 , \"maxSize\": 8192, \"pbfAlias\": \"pbf\" , \"styles\":  \"custom\":  \"style\": \"custom.json\", \"tilejson\":  \"bounds\": [-180, -90, 180, 90]   , \"data\":  \"v3\":  \"mbtiles\": \"zurich.mbtiles\"   "
metadata:
  name: map-tile-server-config
  namespace: test
---
apiVersion: v1
kind: ConfigMap
data:
  custom.json: " \"version\": 8, \"name\": \"Custom\",  \"metadata\":  \"mapbox:autocomposite\": false, \"mapbox:type\": \"template\", \"maputnik:renderer\": \"mbgljs\", \"openmaptiles:version\": \"3.x\", \"openmaptiles:mapbox:owner\": \"openmaptiles\", \"openmaptiles:mapbox:source:url\": \"mapbox://openmaptiles.4qljc88t\"  ,  \"sources\": \"openmaptiles\": \"type\": \"vector\", \"url\": \"mbtiles://v3\",  \"sprite\": \"\",  \"glyphs\": \"fontstack/range.pbf\",  \"layers\": [ \"id\": \"background\",\"type\": \"background\",\"layout\": \"visibility\": \"visible\",\"paint\": \"background-color\": \"rgba(49, 52, 56, 1)\" , \"id\": \"landuse-residential\",\"type\": \"fill\",\"source\": \"openmaptiles\",\"source-layer\": \"landuse\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"Polygon\"],  [\"in\", \"class\", \"residential\", \"suburb\", \"neighbourhood\"]],\"layout\": \"visibility\": \"none\",\"paint\": \"fill-color\": \"hsl(47, 13%, 86%)\", \"fill-opacity\": 0.7 , \"id\": \"landcover_grass\",\"type\": \"fill\",\"source\": \"openmaptiles\",\"source-layer\": \"landcover\",\"filter\": [\"==\", \"class\", \"grass\"],\"layout\": \"visibility\": \"none\",\"paint\": \"fill-color\": \"hsl(82, 46%, 72%)\", \"fill-opacity\": 0.45 , \"id\": \"landcover_wood\",\"type\": \"fill\",\"source\": \"openmaptiles\",\"source-layer\": \"landcover\",\"filter\": [\"==\", \"class\", \"wood\"],\"layout\": \"visibility\": \"none\",\"paint\":   \"fill-color\": \"hsl(82, 46%, 72%)\",  \"fill-opacity\": \"base\": 1, \"stops\": [[8, 0.6], [22, 1]] , \"id\": \"water\",\"type\": \"fill\",\"source\": \"openmaptiles\",\"source-layer\": \"water\",\"filter\": [\"all\", [\"==\", \"$type\", \"Polygon\"], [\"!=\", \"intermittent\", 1]],\"layout\": \"visibility\": \"visible\",\"paint\": \"fill-color\": \"rgba(34, 35, 40, 1)\" , \"id\": \"water_intermittent\",\"type\": \"fill\",\"source\": \"openmaptiles\",\"source-layer\": \"water\",\"filter\": [\"all\", [\"==\", \"$type\", \"Polygon\"], [\"==\", \"intermittent\", 1]],\"layout\": \"visibility\": \"none\",\"paint\": \"fill-color\": \"hsl(205, 56%, 73%)\", \"fill-opacity\": 0.7 , \"id\": \"landcover-ice-shelf\",\"type\": \"fill\",\"source\": \"openmaptiles\",\"source-layer\": \"landcover\",\"filter\": [\"==\", \"subclass\", \"ice_shelf\"],\"layout\": \"visibility\": \"none\",\"paint\": \"fill-color\": \"hsl(47, 26%, 88%)\", \"fill-opacity\": 0.8 , \"id\": \"landcover-glacier\",\"type\": \"fill\",\"source\": \"openmaptiles\",\"source-layer\": \"landcover\",\"filter\": [\"==\", \"subclass\", \"glacier\"],\"layout\": \"visibility\": \"none\",\"paint\":   \"fill-color\": \"hsl(47, 22%, 94%)\",  \"fill-opacity\": \"base\": 1, \"stops\": [[0, 1], [8, 0.5]] , \"id\": \"landcover_sand\",\"type\": \"fill\",\"metadata\": ,\"source\": \"openmaptiles\",\"source-layer\": \"landcover\",\"filter\": [\"all\", [\"in\", \"class\", \"sand\"]],\"layout\": \"visibility\": \"none\",\"paint\":   \"fill-antialias\": false,  \"fill-color\": \"rgba(232, 214, 38, 1)\",  \"fill-opacity\": 0.3 , \"id\": \"landuse\",\"type\": \"fill\",\"source\": \"openmaptiles\",\"source-layer\": \"landuse\",\"filter\": [\"==\", \"class\", \"agriculture\"],\"layout\": \"visibility\": \"none\",\"paint\": \"fill-color\": \"#eae0d0\" , \"id\": \"landuse_overlay_national_park\",\"type\": \"fill\",\"source\": \"openmaptiles\",\"source-layer\": \"landcover\",\"filter\": [\"==\", \"class\", \"national_park\"],\"layout\": \"visibility\": \"none\",\"paint\":   \"fill-color\": \"#E1EBB0\",  \"fill-opacity\": \"base\": 1, \"stops\": [[5, 0], [9, 0.75]] , \"id\": \"waterway-tunnel\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"waterway\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"==\", \"brunnel\", \"tunnel\"]],\"layout\": \"visibility\": \"none\",\"paint\":   \"line-color\": \"hsl(205, 56%, 73%)\",  \"line-dasharray\": [3, 3],  \"line-gap-width\": \"stops\": [[12, 0], [20, 6]],  \"line-opacity\": 1,  \"line-width\": \"base\": 1.4, \"stops\": [[8, 1], [20, 2]] , \"id\": \"waterway\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"waterway\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"!in\", \"brunnel\", \"tunnel\", \"bridge\"],  [\"!=\", \"intermittent\", 1]],\"layout\": \"visibility\": \"none\",\"paint\":   \"line-color\": \"hsl(205, 56%, 73%)\",  \"line-opacity\": 1,  \"line-width\": \"base\": 1.4, \"stops\": [[8, 1], [20, 8]] , \"id\": \"waterway_intermittent\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"waterway\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"!in\", \"brunnel\", \"tunnel\", \"bridge\"],  [\"==\", \"intermittent\", 1]],\"layout\": \"visibility\": \"none\",\"paint\":   \"line-color\": \"hsl(205, 56%, 73%)\",  \"line-opacity\": 1,  \"line-width\": \"base\": 1.4, \"stops\": [[8, 1], [20, 8]],  \"line-dasharray\": [2, 1] , \"id\": \"tunnel_railway_transit\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"minzoom\": 0,\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"==\", \"brunnel\", \"tunnel\"],  [\"==\", \"class\", \"transit\"]],\"layout\":   \"line-cap\": \"butt\",  \"line-join\": \"miter\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"hsl(34, 12%, 66%)\",  \"line-dasharray\": [3, 3],  \"line-opacity\": \"base\": 1, \"stops\": [[11, 0], [16, 1]] , \"id\": \"building\",\"type\": \"fill\",\"source\": \"openmaptiles\",\"source-layer\": \"building\",\"layout\": \"visibility\": \"none\",\"paint\":   \"fill-antialias\": true,  \"fill-color\": \"rgba(222, 211, 190, 1)\",  \"fill-opacity\": \"base\": 1, \"stops\": [[13, 0], [15, 1]],  \"fill-outline-color\":  \"stops\": [[15, \"rgba(212, 177, 146, 0)\"],[16, \"rgba(212, 177, 146, 0.5)\"] ]   , \"id\": \"housenumber\",\"type\": \"symbol\",\"source\": \"openmaptiles\",\"source-layer\": \"housenumber\",\"minzoom\": 17,\"filter\": [\"==\", \"$type\", \"Point\"],\"layout\":   \"text-field\": \"housenumber\",  \"text-font\": [\"Noto Sans Regular\"],  \"text-size\": 10,  \"visibility\": \"none\",\"paint\": \"text-color\": \"rgba(212, 177, 146, 1)\" , \"id\": \"road_area_pier\",\"type\": \"fill\",\"metadata\": ,\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [\"all\", [\"==\", \"$type\", \"Polygon\"], [\"==\", \"class\", \"pier\"]],\"layout\": \"visibility\": \"none\",\"paint\": \"fill-color\": \"hsl(47, 26%, 88%)\", \"fill-antialias\": true , \"id\": \"road_pier\",\"type\": \"line\",\"metadata\": ,\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [\"all\", [\"==\", \"$type\", \"LineString\"], [\"in\", \"class\", \"pier\"]],\"layout\":   \"line-cap\": \"round\",  \"line-join\": \"round\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"hsl(47, 26%, 88%)\",  \"line-width\": \"base\": 1.2, \"stops\": [[15, 1], [17, 4]] , \"id\": \"road_bridge_area\",\"type\": \"fill\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"Polygon\"],  [\"in\", \"brunnel\", \"bridge\"]],\"layout\": \"visibility\": \"none\",\"paint\": \"fill-color\": \"hsl(47, 26%, 88%)\", \"fill-opacity\": 0.5 , \"id\": \"road_path\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"in\", \"class\", \"path\", \"track\"]],\"layout\":   \"line-cap\": \"square\",  \"line-join\": \"bevel\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"hsl(0, 0%, 97%)\",  \"line-dasharray\": [1, 1],  \"line-width\": \"base\": 1.55, \"stops\": [[4, 0.25], [20, 10]] , \"id\": \"road_minor\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"minzoom\": 13,\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"in\", \"class\", \"minor\", \"service\"]],\"layout\":   \"line-cap\": \"round\",  \"line-join\": \"round\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"hsl(0, 0%, 97%)\",  \"line-width\": \"base\": 1.55, \"stops\": [[4, 0.25], [20, 30]] , \"id\": \"tunnel_minor\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"==\", \"brunnel\", \"tunnel\"],  [\"==\", \"class\", \"minor_road\"]],\"layout\":   \"line-cap\": \"butt\",  \"line-join\": \"miter\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"#efefef\",  \"line-dasharray\": [0.36, 0.18],  \"line-width\": \"base\": 1.55, \"stops\": [[4, 0.25], [20, 30]] , \"id\": \"tunnel_major\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"==\", \"brunnel\", \"tunnel\"],  [\"in\", \"class\", \"primary\", \"secondary\", \"tertiary\", \"trunk\"]],\"layout\":   \"line-cap\": \"butt\",  \"line-join\": \"miter\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"#fff\",  \"line-dasharray\": [0.28, 0.14],  \"line-width\": \"base\": 1.4, \"stops\": [[6, 0.5], [20, 30]] , \"id\": \"aeroway-area\",\"type\": \"fill\",\"metadata\": \"mapbox:group\": \"1444849345966.4436\",\"source\": \"openmaptiles\",\"source-layer\": \"aeroway\",\"minzoom\": 4,\"filter\": [  \"all\",  [\"==\", \"$type\", \"Polygon\"],  [\"in\", \"class\", \"runway\", \"taxiway\"]],\"layout\": \"visibility\": \"none\",\"paint\":   \"fill-color\": \"rgba(255, 255, 255, 1)\",  \"fill-opacity\": \"base\": 1, \"stops\": [[13, 0], [14, 1]] , \"id\": \"aeroway-taxiway\",\"type\": \"line\",\"metadata\": \"mapbox:group\": \"1444849345966.4436\",\"source\": \"openmaptiles\",\"source-layer\": \"aeroway\",\"minzoom\": 12,\"filter\": [  \"all\",  [\"in\", \"class\", \"taxiway\"],  [\"==\", \"$type\", \"LineString\"]],\"layout\":   \"line-cap\": \"round\",  \"line-join\": \"round\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"rgba(255, 255, 255, 1)\",  \"line-opacity\": 1,  \"line-width\": \"base\": 1.5, \"stops\": [[12, 1], [17, 10]] , \"id\": \"aeroway-runway\",\"type\": \"line\",\"metadata\": \"mapbox:group\": \"1444849345966.4436\",\"source\": \"openmaptiles\",\"source-layer\": \"aeroway\",\"minzoom\": 4,\"filter\": [  \"all\",  [\"in\", \"class\", \"runway\"],  [\"==\", \"$type\", \"LineString\"]],\"layout\":   \"line-cap\": \"round\",  \"line-join\": \"round\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"rgba(255, 255, 255, 1)\",  \"line-opacity\": 1,  \"line-width\": \"base\": 1.5, \"stops\": [[11, 4], [17, 50]] , \"id\": \"road_trunk_primary\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"in\", \"class\", \"trunk\", \"primary\"]],\"layout\":   \"line-cap\": \"round\",  \"line-join\": \"round\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"#fff\",  \"line-width\": \"base\": 1.4, \"stops\": [[6, 0.5], [20, 30]] , \"id\": \"road_secondary_tertiary\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"in\", \"class\", \"secondary\", \"tertiary\"]],\"layout\":   \"line-cap\": \"round\",  \"line-join\": \"round\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"#fff\",  \"line-width\": \"base\": 1.4, \"stops\": [[6, 0.5], [20, 20]] , \"id\": \"road_major_motorway\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"==\", \"class\", \"motorway\"]],\"layout\":   \"line-cap\": \"round\",  \"line-join\": \"round\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"hsl(0, 0%, 100%)\",  \"line-offset\": 0,  \"line-width\": \"base\": 1.4, \"stops\": [[8, 1], [16, 10]] , \"id\": \"railway-transit\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [  \"all\",  [\"==\", \"class\", \"transit\"],  [\"!=\", \"brunnel\", \"tunnel\"]],\"layout\": \"visibility\": \"none\",\"paint\":   \"line-color\": \"hsl(34, 12%, 66%)\",  \"line-opacity\": \"base\": 1, \"stops\": [[11, 0], [16, 1]] , \"id\": \"railway\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [\"==\", \"class\", \"rail\"],\"layout\": \"visibility\": \"none\",\"paint\":   \"line-color\": \"hsl(34, 12%, 66%)\",  \"line-opacity\": \"base\": 1, \"stops\": [[11, 0], [16, 1]] , \"id\": \"waterway-bridge-case\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"waterway\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"==\", \"brunnel\", \"bridge\"]],\"layout\":   \"line-cap\": \"butt\",  \"line-join\": \"miter\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"#bbbbbb\",  \"line-gap-width\": \"base\": 1.55, \"stops\": [[4, 0.25], [20, 30]],  \"line-width\": \"base\": 1.6, \"stops\": [[12, 0.5], [20, 10]] , \"id\": \"waterway-bridge\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"waterway\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"==\", \"brunnel\", \"bridge\"]],\"layout\":   \"line-cap\": \"round\",  \"line-join\": \"round\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"hsl(205, 56%, 73%)\",  \"line-width\": \"base\": 1.55, \"stops\": [[4, 0.25], [20, 30]] , \"id\": \"bridge_minor case\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"==\", \"brunnel\", \"bridge\"],  [\"==\", \"class\", \"minor_road\"]],\"layout\":   \"line-cap\": \"butt\",  \"line-join\": \"miter\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"#dedede\",  \"line-gap-width\": \"base\": 1.55, \"stops\": [[4, 0.25], [20, 30]],  \"line-width\": \"base\": 1.6, \"stops\": [[12, 0.5], [20, 10]] , \"id\": \"bridge_major case\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"==\", \"brunnel\", \"bridge\"],  [\"in\", \"class\", \"primary\", \"secondary\", \"tertiary\", \"trunk\"]],\"layout\":   \"line-cap\": \"butt\",  \"line-join\": \"miter\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"#dedede\",  \"line-gap-width\": \"base\": 1.55, \"stops\": [[4, 0.25], [20, 30]],  \"line-width\": \"base\": 1.6, \"stops\": [[12, 0.5], [20, 10]] , \"id\": \"bridge_minor\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"==\", \"brunnel\", \"bridge\"],  [\"==\", \"class\", \"minor_road\"]],\"layout\":   \"line-cap\": \"round\",  \"line-join\": \"round\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"#efefef\",  \"line-width\": \"base\": 1.55, \"stops\": [[4, 0.25], [20, 30]] , \"id\": \"bridge_major\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation\",\"filter\": [  \"all\",  [\"==\", \"$type\", \"LineString\"],  [\"==\", \"brunnel\", \"bridge\"],  [\"in\", \"class\", \"primary\", \"secondary\", \"tertiary\", \"trunk\"]],\"layout\":   \"line-cap\": \"round\",  \"line-join\": \"round\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"#fff\",  \"line-width\": \"base\": 1.4, \"stops\": [[6, 0.5], [20, 30]] , \"id\": \"admin_sub\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"boundary\",\"filter\": [\"in\", \"admin_level\", 4, 6, 8],\"layout\": \"visibility\": \"none\",\"paint\": \"line-color\": \"hsla(0, 0%, 60%, 0.5)\", \"line-dasharray\": [2, 1] , \"id\": \"admin_country\",\"type\": \"line\",\"source\": \"openmaptiles\",\"source-layer\": \"boundary\",\"filter\": [  \"all\",  [\"<=\", \"admin_level\", 2],  [\"==\", \"$type\", \"LineString\"]],\"layout\":   \"line-cap\": \"round\",  \"line-join\": \"round\",  \"visibility\": \"none\",\"paint\":   \"line-color\": \"hsl(0, 0%, 60%)\",  \"line-width\": \"base\": 1.3, \"stops\": [[3, 0.5], [22, 15]] , \"id\": \"poi_label\",\"type\": \"symbol\",\"source\": \"openmaptiles\",\"source-layer\": \"poi\",\"minzoom\": 14,\"filter\": [\"all\", [\"==\", \"$type\", \"Point\"], [\"==\", \"rank\", 1]],\"layout\":   \"icon-size\": 1,  \"text-anchor\": \"top\",  \"text-field\": \"name:latin\\nname:nonlatin\",  \"text-font\": [\"Noto Sans Regular\"],  \"text-max-width\": 8,  \"text-offset\": [0, 0.5],  \"text-size\": 11,  \"visibility\": \"none\",\"paint\":   \"text-color\": \"#666\",  \"text-halo-blur\": 1,  \"text-halo-color\": \"rgba(255,255,255,0.75)\",  \"text-halo-width\": 1 , \"id\": \"airport-label\",\"type\": \"symbol\",\"source\": \"openmaptiles\",\"source-layer\": \"aerodrome_label\",\"minzoom\": 10,\"filter\": [\"all\", [\"has\", \"iata\"]],\"layout\":   \"icon-size\": 1,  \"text-anchor\": \"top\",  \"text-field\": \"name:latin\\nname:nonlatin\",  \"text-font\": [\"Noto Sans Regular\"],  \"text-max-width\": 8,  \"text-offset\": [0, 0.5],  \"text-size\": 11,  \"visibility\": \"none\",\"paint\":   \"text-color\": \"#666\",  \"text-halo-blur\": 1,  \"text-halo-color\": \"rgba(255,255,255,0.75)\",  \"text-halo-width\": 1 , \"id\": \"road_major_label\",\"type\": \"symbol\",\"source\": \"openmaptiles\",\"source-layer\": \"transportation_name\",\"filter\": [\"==\", \"$type\", \"LineString\"],\"layout\":   \"symbol-placement\": \"line\",  \"text-field\": \"name:latin name:nonlatin\",  \"text-font\": [\"Noto Sans Regular\"],  \"text-letter-spacing\": 0.1,  \"text-rotation-alignment\": \"map\",  \"text-size\": \"base\": 1.4, \"stops\": [[10, 8], [20, 14]], \"text-transform\": \"uppercase\", \"visibility\": \"none\",\"paint\":  \"text-color\": \"#000\", \"text-halo-color\": \"hsl(0, 0%, 100%)\", \"text-halo-width\": 2 , \"id\": \"place_label_other\",\"type\": \"symbol\",\"source\": \"openmaptiles\",\"source-layer\": \"place\",\"minzoom\": 8,\"filter\": [ \"all\", [\"==\", \"$type\", \"Point\"], [\"!in\", \"class\", \"city\", \"state\", \"country\", \"continent\"]],\"layout\":  \"text-anchor\": \"center\", \"text-field\": \"name:latin\\nname:nonlatin\", \"text-font\": [\"Noto Sans Regular\"], \"text-max-width\": 6, \"text-size\": \"stops\": [[6, 10], [12, 14]], \"visibility\": \"none\",\"paint\":  \"text-color\": \"hsl(0, 0%, 25%)\", \"text-halo-blur\": 0, \"text-halo-color\": \"hsl(0, 0%, 100%)\", \"text-halo-width\": 2 , \"id\": \"place_label_city\",\"type\": \"symbol\",\"source\": \"openmaptiles\",\"source-layer\": \"place\",\"maxzoom\": 16,\"filter\": [\"all\", [\"==\", \"$type\", \"Point\"], [\"==\", \"class\", \"city\"]],\"layout\":  \"text-field\": \"name:latin\\nname:nonlatin\", \"text-font\": [\"Noto Sans Regular\"], \"text-max-width\": 10, \"text-size\": \"stops\": [[3, 12], [8, 16]], \"visibility\": \"none\",\"paint\":  \"text-color\": \"hsl(0, 0%, 0%)\", \"text-halo-blur\": 0, \"text-halo-color\": \"hsla(0, 0%, 100%, 0.75)\", \"text-halo-width\": 2 , \"id\": \"country_label-other\",\"type\": \"symbol\",\"source\": \"openmaptiles\",\"source-layer\": \"place\",\"maxzoom\": 12,\"filter\": [ \"all\", [\"==\", \"$type\", \"Point\"], [\"==\", \"class\", \"country\"], [\"!has\", \"iso_a2\"]],\"layout\":  \"text-field\": \"name:latin\", \"text-font\": [\"Noto Sans Regular\"], \"text-max-width\": 10, \"text-size\": \"stops\": [[3, 12], [8, 22]], \"visibility\": \"none\",\"paint\":  \"text-color\": \"hsl(0, 0%, 13%)\", \"text-halo-blur\": 0, \"text-halo-color\": \"rgba(255,255,255,0.75)\", \"text-halo-width\": 2 , \"id\": \"country_label\",\"type\": \"symbol\",\"source\": \"openmaptiles\",\"source-layer\": \"place\",\"maxzoom\": 12,\"filter\": [ \"all\", [\"==\", \"$type\", \"Point\"], [\"==\", \"class\", \"country\"], [\"has\", \"iso_a2\"]],\"layout\":  \"text-field\": \"name:latin\", \"text-font\": [\"Noto Sans Bold\"], \"text-max-width\": 10, \"text-size\": \"stops\": [[3, 12], [8, 22]], \"visibility\": \"none\",\"paint\":  \"text-color\": \"hsl(0, 0%, 13%)\", \"text-halo-blur\": 0, \"text-halo-color\": \"rgba(255,255,255,0.75)\", \"text-halo-width\": 2  ], \"id\": \"basic\""
metadata:
  name: map-tile-server-style-config
  namespace: test

【问题讨论】:

这个 custom.json 有特定的结构吗?因为 configmaps 将所有内容都列为 key:value 对。另外,您没有将custom.json configmap 添加到问题中,它真的部署了吗? 我可以确认两个 ConfigMap 都已部署。我在问题中添加了custom.json ConfigMap。 custom.json 具有 tileserver-gl 使用的样式结构。我在我的机器上使用Kitematictileserver-gl 对它进行了本地测试,custom.json 按预期工作。 我想我可能需要从InitContainer 下载自定义.mbtiles 文件。似乎当 tileserver-gl 没有找到.mbtiles 文件时,它会初始化一个示例.mbtiles 文件并为该文件创建自己的config.json 现在检查您的 json,结构似乎保存完好。使用那个 .mbtiles 进行测试,因为您在 kubernetes 中的结构似乎是正确的。 【参考方案1】:

我对您的环境进行了更深入的研究,并将其部署在我的本地集群上,以下是我的发现:

当我按照您的问题部署您的 yaml 时,看看文件最终挂载在哪里:
$ kubectl get pods
NAME                               READY   STATUS              RESTARTS   AGE
map-tile-server-5c86b677df-wswwz   1/1     Running             0          2s

$ kubectl exec -it map-tile-server-5cb677df-wswwz /bin/bash --
root@map-tile-server-5c86b677df-wswwz:/# ls -l
drwxrwxrwx   3 root root 4096 Apr 10 12:16 config.json
drwxr-xr-x   3 root root 4096 Apr 10 12:16 styles

root@map-tile-server-5c86b677df-wswwz:/config.json# ls -l
lrwxrwxrwx 1 root root 18 Apr 10 12:16 config.json -> ..data/config.json

root@map-tile-server-5c86b677df-wswwz:/styles# ls -l
drwxrwxrwx 3 root root 4096 Apr 10 12:16 custom.json

root@map-tile-server-5c86b677df-wswwz:/styles# cd custom.json/
root@map-tile-server-5c86b677df-wswwz:/styles/custom.json# ls -l
lrwxrwxrwx 1 root root 18 Apr 10 12:16 custom.json -> ..data/custom.json

它正在使用文件名创建文件夹,并在每个文件夹中插入您的配置映射。

在您的问题中,您提到您希望将此文件放在/config.json/styles/custom.json,我想和您评论两件事:

你不能设置config.json直接挂载到/,容器不会运行,因为你“覆盖”了/文件夹。所以你的 config.json 需要保留在某个文件夹中,最佳做法是直接挂载在/data 目录中。

虽然有一个符号链接将/styles/custom.json/custom.json 文件指向data/custom.json,但还是要提醒您:

如果您在 config.json 中提及路径 /style/custom.json,它将不会在那里找到该文件

您可以在此处查看How to Mount ConfigMaps as Files 上的 Kubernetes 文档中提供的示例

这些是我对您的 yaml 所做的更改,以将 custom.json 文件移动到预期路径:
          volumeMounts:
            - name: map-tile-server-config
              mountPath: /config.json
            - name: map-tile-server-style-config
              mountPath: /styles
      volumes:
        - name: map-tile-server-config
          configMap:
            name: map-tile-server-config
        - name: map-tile-server-style-config
          configMap:
            name: map-tile-server-style-config
现在让我们测试一下:
$ kubectl get pods
NAME                               READY   STATUS    RESTARTS   AGE
map-tile-server-5cd7694b74-s6g6g   1/1     Running   0          8s

$ kubectl exec -it map-tile-server-5cd7694b74-s6g6g -- /bin/bash
root@map-tile-server-5cd7694b74-s6g6g:/# ls
bin  boot  config.json  data  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  styles  sys  tmp  usr  var

root@map-tile-server-5cd7694b74-s6g6g:/config.json# ls -l
lrwxrwxrwx 1 root root 18 Apr 10 12:27 config.json -> ..data/config.json

root@map-tile-server-5cd7694b74-s6g6g:/styles# ls -l
lrwxrwxrwx 1 root root 18 Apr 10 12:27 custom.json -> ..data/custom.json

现在文件位于预期位置。

我的建议是稍后简化您的管理,例如安装到:
          volumeMounts:
            - name: map-tile-server-config
              mountPath: /data/config
            - name: map-tile-server-style-config
              mountPath: /data/styles
将输出数据文件夹中的所有内容:
owilliam@minikube-usc1a:~/CaseFiles/configmap-json$ k exec -it map-tile-server-6b5fc64fd6-6g2wb -- /bin/bash
root@map-tile-server-6b5fc64fd6-6g2wb:/data# ls
config  styles  zurich_switzerland.mbtiles
root@map-tile-server-6b5fc64fd6-6g2wb:/data# ls -l 
total 23684
drwxrwxrwx 3 root root     4096 Apr 10 13:22 config
drwxrwxrwx 3 root root     4096 Apr 10 13:22 styles
-rw-r--r-- 1 root root 24244224 Apr 10 13:22 zurich_switzerland.mbtiles
root@map-tile-server-6b5fc64fd6-6g2wb:/data# ls config
config.json
root@map-tile-server-6b5fc64fd6-6g2wb:/data# ls styles

如果您有任何问题,请在 cmets 中告诉我。

【讨论】:

这真的很有帮助。谢谢你的详细回复。它现在正在工作。我使用 InitContainer 进行 mbtiles 文件设置,然后修复了 configMap 路径。

以上是关于使用带有自定义配置和样式文件的 Kubernetes for TileServer-GL的主要内容,如果未能解决你的问题,请参考以下文章

使用带有Notify.js jQuery插件的外部自定义CSS

使用带有自定义引导样式的 Django 模板放置 <select> 字段

Toolbar自定义样式配置及用法

webpack 配置scssless全局样式(自定义的,vue-cli2/3)

自定义属性未在样式和主题中解析

带有样式组件的 React-slick 自定义箭头