Advertisement
krak3n

namerd kubernetes config

Oct 4th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 6.06 KB | None | 0 0
  1. #
  2. # Namerd Kubernetes Deployment
  3. #
  4. ---
  5. # Third Party Resource
  6. #
  7. # Note: Third Party Resources are due to be removed in 1.8
  8. # This should be updated to a Custom Resouce Definition
  9. # Waiting on word from Buoyant about that on github.com issue
  10. kind: ThirdPartyResource
  11. apiVersion: extensions/v1beta1
  12. metadata:
  13.   name: d-tab.l5d.io
  14. description: stores dtabs used by namerd
  15. versions:
  16. - name: v1alpha1
  17. ---
  18. # Configuration
  19. apiVersion: v1
  20. kind: ConfigMap
  21. metadata:
  22.   name: namerd-config
  23. data:
  24.   config.yaml: |-
  25.     admin:
  26.       ip: 0.0.0.0
  27.       port: 9991
  28.     namers:
  29.     - kind: io.l5d.k8s
  30.       experimental: true
  31.       host: localhost
  32.       port: 8001
  33.     storage:
  34.       kind: io.l5d.k8s
  35.       host: localhost
  36.       port: 8001
  37.       namespace: default
  38.     interfaces:
  39.     - kind: io.l5d.thriftNameInterpreter
  40.       ip: 0.0.0.0
  41.       port: 4100
  42.     - kind: io.l5d.httpController
  43.       ip: 0.0.0.0
  44.       port: 4180
  45. ---
  46. # Replication Controller
  47. kind: ReplicationController
  48. apiVersion: v1
  49. metadata:
  50.   name: namerd
  51. spec:
  52.   replicas: 3
  53.   selector:
  54.     app: namerd
  55.   template:
  56.     metadata:
  57.       labels:
  58.         app: namerd
  59.     spec:
  60.       dnsPolicy: ClusterFirst
  61.       volumes:
  62.       - name: namerd-config
  63.         configMap:
  64.           name: namerd-config
  65.       containers:
  66.       - name: namerd
  67.         image: buoyantio/namerd:1.2.0
  68.         args:
  69.        - /io.buoyant/namerd/config/config.yaml
  70.         ports:
  71.         - name: thrift
  72.           containerPort: 4100
  73.         - name: http
  74.           containerPort: 4180
  75.         - name: admin
  76.           containerPort: 9991
  77.         volumeMounts:
  78.         - name: "namerd-config"
  79.           mountPath: "/io.buoyant/namerd/config"
  80.           readOnly: true
  81.       - name: kubectl
  82.         image: buoyantio/kubectl:v1.4.0
  83.         args:
  84.        - "proxy"
  85.         - "-p"
  86.         - "8001"
  87. ---
  88. # Namerd Service
  89. apiVersion: v1
  90. kind: Service
  91. metadata:
  92.   name: namerd
  93. spec:
  94.   selector:
  95.     app: namerd
  96.   type: ClusterIP
  97.   ports:
  98.   - name: http-outgoing
  99.     port: 4140
  100.   - name: http-incoming
  101.     port: 4141
  102.   - name: h2-outgoing
  103.     port: 4240
  104.   - name: h2-incoming
  105.     port: 4241
  106.   - name: grpc-outgoing
  107.     port: 4340
  108.   - name: grpc-incoming
  109.     port: 4341
  110.   - name: http-ingress
  111.     port: 80
  112.   - name: h2-ingress
  113.     port: 8080
  114.   - name: thrift
  115.     port: 4100
  116.   - name: http
  117.     port: 4180
  118.   - name: admin
  119.     port: 9991
  120. ---
  121. #
  122. # Job to setup default dtabs to enusre our default
  123. # routing is setup for http, http2 and GRPC
  124. # This are taken from the linkerd example default configs
  125. #
  126. ---
  127. # Script to create dtabs using namerctl
  128. kind: ConfigMap
  129. apiVersion: v1
  130. metadata:
  131.   name: namerctl-script
  132. data:
  133.   createNs.sh: |-
  134.     #!/bin/sh
  135.     # HTTP/1.1 Incoming
  136.     set -e
  137.     if namerctl dtab get http-incoming > /dev/null 2>&1; then
  138.       echo "http-incoming dtab already exists"
  139.     else
  140.       echo "
  141.        /k8s => /#/io.l5d.k8s ;
  142.        /portNsSvc => /#/portNsSvcToK8s ;
  143.        /host => /portNsSvc/http/default ;
  144.        /host => /portNsSvc/http ;
  145.        /svc => /$/io.buoyant.http.domainToPathPfx/host ;
  146.      " | namerctl dtab create http-incoming -
  147.     fi
  148.     # HTTP/1.1 Outgoing
  149.     if namerctl dtab get http-outgoing > /dev/null 2>&1; then
  150.       echo "http-outgoing dtab already exists"
  151.     else
  152.       echo "
  153.        /ph  => /$/io.buoyant.rinet ;
  154.        /svc => /ph/80 ;
  155.        /svc => /$/io.buoyant.porthostPfx/ph ;
  156.        /k8s => /#/io.l5d.k8s.h2 ;
  157.        /portNsSvc => /#/portNsSvcToK8s ;
  158.        /host => /portNsSvc/h2/default ;
  159.        /host => /portNsSvc/h2 ;
  160.        /svc => /$/io.buoyant.http.domainToPathPfx/host ;
  161.      " | namerctl dtab create http-outgoing -
  162.     fi
  163.     # HTTP/2 Incoming
  164.     set -e
  165.     if namerctl dtab get h2-incoming > /dev/null 2>&1; then
  166.       echo "h2-incoming dtab already exists"
  167.     else
  168.       echo "
  169.        /k8s => /#/io.l5d.k8s ;
  170.        /portNsSvc => /#/portNsSvcToK8s ;
  171.        /host => /portNsSvc/h2/default ;
  172.        /host => /portNsSvc/h2 ;
  173.        /svc => /$/io.buoyant.http.domainToPathPfx/host ;
  174.      " | namerctl dtab create h2-incoming -
  175.     fi
  176.     # HTTP/2 Outgoing
  177.     if namerctl dtab get h2-outgoing > /dev/null 2>&1; then
  178.       echo "h2-outgoing dtab already exists"
  179.     else
  180.       echo "
  181.        /ph  => /$/io.buoyant.rinet ;
  182.        /svc => /ph/80 ;
  183.        /svc => /$/io.buoyant.porthostPfx/ph ;
  184.        /k8s => /#/io.l5d.k8s.h2 ;
  185.        /portNsSvc => /#/portNsSvcToK8s ;
  186.        /host => /portNsSvc/h2/default ;
  187.        /host => /portNsSvc/h2 ;
  188.        /svc => /$/io.buoyant.http.domainToPathPfx/host ;
  189.      " | namerctl dtab create h2-outgoing -
  190.     fi
  191.     # gRPC Incoming
  192.     set -e
  193.     if namerctl dtab get grpc-incoming > /dev/null 2>&1; then
  194.       echo "grpc-incoming dtab already exists"
  195.     else
  196.       echo "
  197.        /srv => /#/io.l5d.k8s/default/grpc ;
  198.        /svc => /$/io.buoyant.http.domainToPathPfx/srv ;
  199.      " | namerctl dtab create grpc-incoming -
  200.     fi
  201.     # gRPC Outgoing
  202.     if namerctl dtab get grpc-outgoing > /dev/null 2>&1; then
  203.       echo "grpc-outgoing dtab already exists"
  204.     else
  205.       echo "
  206.        /svc => /$/io.buoyant.hostportPfx/hp ;
  207.        /srv => /#/io.l5d.k8s.grpc/default/grpc;
  208.        /svc => /$/io.buoyant.http.domainToPathPfx/srv ;
  209.      " | namerctl dtab create grpc-outgoing -
  210.     fi
  211. ---
  212. # Job which is run only once to bootstrap namerd
  213. # To re-run this job delete it in kubernetes and apply this config
  214. kind: Job
  215. apiVersion: batch/v1
  216. metadata:
  217.   name: namerctl
  218. spec:
  219.   template:
  220.     metadata:
  221.       name: namerctl
  222.     spec:
  223.       volumes:
  224.       - name: namerctl-script
  225.         configMap:
  226.           name: namerctl-script
  227.           defaultMode: 0755
  228.       containers:
  229.       - name: namerctl
  230.         image: linkerd/namerctl:0.8.6
  231.         env:
  232.         - name: NAMERCTL_BASE_URL
  233.           value: http://namerd.default.svc.cluster.local:4180
  234.         command:
  235.        - "/namerctl/createNs.sh"
  236.         volumeMounts:
  237.         - name: "namerctl-script"
  238.           mountPath: "/namerctl"
  239.           readOnly: true
  240.       restartPolicy: OnFailure
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement