github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/k8s/staging/flow-collection-node-deployment.yml (about)

     1  apiVersion: v1
     2  kind: Service
     3  
     4  metadata:
     5    name: flow-collection-node-ingress-service
     6    namespace: flow
     7  
     8    labels:
     9      app: flow-test-net
    10      node: collection
    11      env: staging
    12      owner: Kan
    13      version: v1
    14  
    15  spec:
    16    type: ClusterIP
    17    selector:
    18      app: flow-test-net
    19      node: collection
    20      env: staging
    21      version: v1
    22    ports:
    23      - name: ingress
    24        protocol: TCP
    25        port: 9000
    26        targetPort: ingress
    27  
    28  ---
    29  # To pre-emptively prepare for the case where we'd want to connect to a specific collection cluster, we can have sub services per cluster
    30  
    31  # Service for accessing the first collection cluster
    32  apiVersion: v1
    33  kind: Service
    34  
    35  metadata:
    36    name: flow-collection-node-v1-0
    37    namespace: flow
    38  
    39    labels:
    40      app: flow-test-net
    41      node: collection
    42      env: staging
    43      owner: Kan
    44      version: v1
    45  
    46  spec:
    47    type: ClusterIP
    48    selector:
    49      app: flow-test-net
    50      node: collection
    51      env: staging
    52      version: v1
    53      statefulset.kubernetes.io/pod-name: flow-collection-node-v1-0
    54  
    55    ports:
    56      - name: ingress
    57        protocol: TCP
    58        port: 9000
    59        targetPort: ingress
    60      - name: grpc
    61        protocol: TCP
    62        port: 3569
    63        targetPort: grpc
    64  
    65  ---
    66  
    67  # Service for accessing the second collection cluster
    68  apiVersion: v1
    69  kind: Service
    70  
    71  metadata:
    72    name: flow-collection-node-v1-1
    73    namespace: flow
    74  
    75    labels:
    76      app: flow-test-net
    77      node: collection
    78      env: staging
    79      owner: Kan
    80      version: v1
    81  
    82  spec:
    83    type: ClusterIP
    84    selector:
    85      app: flow-test-net
    86      node: collection
    87      env: staging
    88      version: v1
    89      statefulset.kubernetes.io/pod-name: flow-collection-node-v1-1
    90  
    91    ports:
    92      - name: ingress
    93        protocol: TCP
    94        port: 9000
    95        targetPort: ingress
    96      - name: grpc
    97        protocol: TCP
    98        port: 3569
    99        targetPort: grpc
   100  
   101  ---
   102  
   103  # Service for accessing the third collection cluster
   104  apiVersion: v1
   105  kind: Service
   106  
   107  metadata:
   108    name: flow-collection-node-v1-2
   109    namespace: flow
   110  
   111    labels:
   112      app: flow-test-net
   113      node: collection
   114      env: staging
   115      owner: Kan
   116      version: v1
   117      statefulset.kubernetes.io/pod-name: flow-collection-node-v1-2
   118  
   119  spec:
   120    type: ClusterIP
   121    selector:
   122      app: flow-test-net
   123      node: collection
   124      env: staging
   125      version: v1
   126  
   127    ports:
   128      - name: ingress
   129        protocol: TCP
   130        port: 9000
   131        targetPort: ingress
   132      - name: grpc
   133        protocol: TCP
   134        port: 3569
   135        targetPort: grpc
   136  
   137  ---
   138  
   139  apiVersion: apps/v1
   140  kind: StatefulSet
   141  metadata:
   142    # This is the full name of your deployment. It must be unique
   143    name: flow-collection-node-v1
   144    namespace: flow
   145  
   146    # Best practice labels:
   147    #   app: <app-name> (the non-unique version of metadata.name)
   148    #   kind: [web|worker]
   149    #   env: [staging|production|test|dev]
   150    #   owner: who to ask about this service
   151    #   version: the major version of this service (v1/v2/v1beta1)
   152    labels:
   153      app: flow-test-net
   154      node: collection
   155      env: staging
   156      owner: Kan
   157      version: v1
   158  
   159  spec:
   160    replicas: 3
   161    serviceName: flow-test-network-v1
   162    selector:
   163      matchLabels:
   164        app: flow-test-net
   165        node: collection
   166        env: staging
   167        version: v1
   168    podManagementPolicy: Parallel
   169    template:
   170      metadata:
   171        annotations:
   172          # Set to "false" to opt out of prometheus scrapes
   173          # Prometheus still needs a port called "metrics" (below) to scrape properly
   174          prometheus.io/scrape: 'true'
   175  
   176          # Set the path to the API endpoint that exposes prometheus metrics, or leave blank for `/metrics`
   177          # prometheus.io/path: "/metrics"
   178  
   179        labels:
   180          app: flow-test-net
   181          node: collection
   182          env: staging
   183          owner: Kan
   184          version: v1
   185          kind: web
   186  
   187      spec:
   188        imagePullSecrets:
   189          - name: gcr
   190        terminationGracePeriodSeconds: 30
   191        containers:
   192          - name: flow-test-net
   193            # No tag, will be attached by teamcity
   194            image: gcr.io/dl-flow/collection
   195            args: 
   196              - '--nodename'
   197              - '$(POD_NAME)'
   198              - '--entries'
   199              - '$(NODE_ENTRIES)'
   200              - '--datadir'
   201              - '/flowdb'
   202              - '--ingress-addr'
   203              - ':9000'
   204  
   205            # Ports exposed can be named so other resources can reference
   206            # them by name and not have to hard code numbers
   207            ports:
   208              - name: grpc
   209                containerPort: 3569
   210              - name: http
   211                containerPort: 8080
   212              - name: ingress
   213                containerPort: 9000
   214              # Prometheus is looking specifically for a port named 'metrics'
   215              # This may be the same as the above port, or different
   216              - name: metrics
   217                containerPort: 8080
   218  
   219            # Environment variables
   220            env:
   221              - name: ENV
   222                value: STAGING
   223              # Cannot get ordinal index yet from metadata at this time: https://github.com/kubernetes/kubernetes/pull/83101/files
   224              # Have to parse out from pod name
   225              - name: POD_NAME
   226                valueFrom:
   227                  fieldRef:
   228                    fieldPath: metadata.name
   229              - name: NODE_ENTRIES
   230                valueFrom:
   231                  configMapKeyRef:
   232                    name: flow-node-config-map
   233                    key: entries
   234              - name: JAEGER_SERVICE_NAME
   235                value: collection
   236              - name: JAEGER_AGENT_HOST
   237                value: jaeger-agent
   238              - name: JAEGER_SAMPLER_TYPE
   239                value: const
   240              - name: JAEGER_SAMPLER_PARAM
   241                value: "1"
   242              - name: JAEGER_REPORTER_LOG_SPANS
   243                value: "true"
   244              # Due to the fact that we're using a headless service, we cannot use the cgo version of net,
   245              # which causes an error, instead, force using the pure go version now
   246              - name: GODEBUG
   247                value: "netdns=go"
   248  
   249            # Resource requests and contraints
   250            resources:
   251              requests:
   252                cpu: '125m'
   253                memory: '128Mi'
   254              limits:
   255                cpu: '250m'
   256                memory: '256Mi'
   257            volumeMounts:
   258              - name: badger-volume
   259                mountPath: /flowdb
   260  
   261            # The current liveness and readiness probes use the /metrics endpoint, which is non-ideal and MVP only
   262            # These probes should eventually make use of the gRPC server's Ping function, or should at least
   263            # be moved over to a /live endpoint that has some introspection into the gRPC's liveness/readiness
   264  
   265            # Readiness Probe
   266            readinessProbe:
   267              httpGet:
   268                path: /metrics
   269                port: http
   270              initialDelaySeconds: 5
   271              successThreshold: 1
   272            
   273            # Liveness Probe
   274            livenessProbe:
   275              httpGet:
   276                path: /metrics
   277                port: http
   278              initialDelaySeconds: 30
   279              periodSeconds: 30
   280              successThreshold: 1
   281  
   282    volumeClaimTemplates:
   283      - metadata:
   284          name: badger-volume
   285        spec:
   286          accessModes:
   287          - ReadWriteOnce
   288          resources:
   289            requests:
   290              storage: 10Gi
   291          storageClassName: standard