Skip to content

1. graph

  • 创建ssl
kubectl create secret tls graph-tls-certificate --namespace default --key server.key --cert server.crt
kubectl create secret tls graph-tls-certificate --namespace default --key server.key --cert server.crt
yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: graph
  labels:
    app: graph
spec:
  replicas: 1
  selector:
    matchLabels:
      app: graph
  template:
    metadata:
      labels:
        app: graph
    spec:
      containers:
      - name: graph
      image: israelhikingmap/graphhopper
      command: ["/bin/bash"]
      args: ["-c", "java -Ddw.graphhopper.datareader.file=/data/europe-latest.osm.pbf -Ddw.server.application_connectors[0].bind_host=0.0.0.0 -Ddw.server.application_connectors[0].port=8989 -jar *.jar server config-example.yml"]
      ports:
      - containerPort: 8989
      volumeMounts:
      - name: graph
        mountPath: "/data/"
    volumes:
    - name: graph
      persistentVolumeClaim:
        claimName: graph
---
apiVersion: v1
kind: Service
metadata:
  name: graph
spec:
  selector:
    app: graph
  ports:
    - protocol: TCP
      port: 8989
      targetPort: 8989
  type: LoadBalancer
  #externalIPs:
  #- Your.external.ip      #uncomment this only if you have local k8s cluster deployment
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  tls:
    - hosts:
      - <your domain URL>
      secretName: graph-tls-certificate
  rules:
    - host: <your domain URL>
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: graph
              port:
                number: 8989
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: graph
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: graph
spec:
  storageClassName: manual
  capacity:
    storage: 1Gi
  accessModes:
  - ReadWriteOnce
hostPath:
  path: /home/root2/graphhopper/data/
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: manual
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: graph-memory-scale
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: graph
minReplicas: 1
maxReplicas: 6
metrics:
- type: Resource
  resource:
    name: memory
    target:
      type: Utilization
      averageValue: 5Gi
apiVersion: apps/v1
kind: Deployment
metadata:
  name: graph
  labels:
    app: graph
spec:
  replicas: 1
  selector:
    matchLabels:
      app: graph
  template:
    metadata:
      labels:
        app: graph
    spec:
      containers:
      - name: graph
      image: israelhikingmap/graphhopper
      command: ["/bin/bash"]
      args: ["-c", "java -Ddw.graphhopper.datareader.file=/data/europe-latest.osm.pbf -Ddw.server.application_connectors[0].bind_host=0.0.0.0 -Ddw.server.application_connectors[0].port=8989 -jar *.jar server config-example.yml"]
      ports:
      - containerPort: 8989
      volumeMounts:
      - name: graph
        mountPath: "/data/"
    volumes:
    - name: graph
      persistentVolumeClaim:
        claimName: graph
---
apiVersion: v1
kind: Service
metadata:
  name: graph
spec:
  selector:
    app: graph
  ports:
    - protocol: TCP
      port: 8989
      targetPort: 8989
  type: LoadBalancer
  #externalIPs:
  #- Your.external.ip      #uncomment this only if you have local k8s cluster deployment
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  tls:
    - hosts:
      - <your domain URL>
      secretName: graph-tls-certificate
  rules:
    - host: <your domain URL>
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: graph
              port:
                number: 8989
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: graph
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: graph
spec:
  storageClassName: manual
  capacity:
    storage: 1Gi
  accessModes:
  - ReadWriteOnce
hostPath:
  path: /home/root2/graphhopper/data/
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: manual
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: graph-memory-scale
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: graph
minReplicas: 1
maxReplicas: 6
metrics:
- type: Resource
  resource:
    name: memory
    target:
      type: Utilization
      averageValue: 5Gi