【发布时间】:2019-08-09 21:39:42
【问题描述】:
我有一个在 Kubernetes 内部运行的应用程序,它需要使用 Leaflet 显示地图,地图数据来自 Openstreetmap。
我用来设置地图的代码如下所示:
map = L.map('mapid', {
center: [lat, long],
zoom: 19
});
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
现在困扰我的是网址{s}.tile.openstreetmap.org。由于 openstreetmap 数据驻留在 k8s 集群之外,我需要在 Kubernetes 中创建一个 Service。
我尝试定义这些服务:
apiVersion: v1
kind: Service
metadata:
name: a.tile.openstreetmap.org
spec:
type: ExternalName
externalName: a.tile.openstreetmap.org
---
apiVersion: v1
kind: Service
metadata:
name: b.tile.openstreetmap.org
spec:
type: ExternalName
externalName: b.tile.openstreetmap.org
---
apiVersion: v1
kind: Service
metadata:
name: c.tile.openstreetmap.org
spec:
type: ExternalName
externalName: c.tile.openstreetmap.org
但是,在部署服务时导致以下错误消息:
Error from server (Invalid): error when creating "openstreetmap-service.yaml": Service "a.tile.openstreetmap.org" is invalid: metadata.name: Invalid value: "a.tile.openstreetmap.org": a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?')
Error from server (Invalid): error when creating "openstreetmap-service.yaml": Service "b.tile.openstreetmap.org" is invalid: metadata.name: Invalid value: "b.tile.openstreetmap.org": a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?')
Error from server (Invalid): error when creating "openstreetmap-service.yaml": Service "c.tile.openstreetmap.org" is invalid: metadata.name: Invalid value: "c.tile.openstreetmap.org": a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?')
我了解我不允许在 .metadata.name 中使用点,但是否有其他可能实现这一点?据我从传单来源的描述中可以看出,TileLayer 中的 URL 需要类似于 http://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png
【问题讨论】:
标签: kubernetes leaflet openstreetmap