---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: javasample
      namespace: webservice
    spec:
      replicas: 1
      selector:
        matchLabels:
          name: webservice
      strategy:
        type: Recreate
      template:
        metadata:
          annotations:
            prometheus.io/port: "3031" # tell prometheus to scrape /metrics endpoint's port.
          labels:
            name: webservice
        spec:
          nodeSelector:
            beta.kubernetes.io/os: linux
          serviceAccountName: webservice
          volumes:
          - name: git-key
            secret:
              secretName: flux-git-deploy
              defaultMode: 0400 # when mounted read-only, we won't be able to chmod
    
          # This is a tmpfs used for generating SSH keys. In K8s >= 1.10,
          # mounted secrets are read-only, so we need a separate volume we
          # can write to.
          - name: git-keygen
            emptyDir:
              medium: Memory
    
          # The following volume is for using a customised known_hosts
          # file, which you will need to do if you host your own git
          # repo rather than using github or the like. You'll also need to
          # mount it into the container, below. See
          # https://docs.fluxcd.io/en/latest/guides/use-private-git-host
          # - name: ssh-config
          #   configMap:
          #     name: flux-ssh-config
    
          # The following volume is for using a customised .kube/config,
          # which you will need to do if you wish to have a different
          # default namespace. You will also need to provide the configmap
          # with an entry for `config`, and uncomment the volumeMount and
          # env entries below.
          # - name: kubeconfig
          #   configMap:
          #     name: flux-kubeconfig
    
          # The following volume is used to import GPG keys (for signing
          # and verification purposes). You will also need to provide the
          # secret with the keys, and uncomment the volumeMount and args
          # below.
          # - name: gpg-keys
          #   secret:
          #     secretName: flux-gpg-keys
          #     defaultMode: 0400
    
          containers:
          - name: javasample
            # There are no ":latest" images for flux. Find the most recent
            # release or image version at https://hub.docker.com/r/fluxcd/flux/tags
            # and replace the tag here.
            image: registry.baidubce.com/service/javasample:latest
            imagePullPolicy: IfNotPresent
            resources:
              requests:
                cpu: 50m
                memory: 64Mi  
            # Include this if you need to mount a customised known_hosts
            # file; you'll also need the volume declared above.
            # - name: ssh-config
            #   mountPath: /root/.ssh
    
            # Include this and the volume "kubeconfig" above, and the
            # environment entry "KUBECONFIG" below, to override the config
            # used by kubectl.
            # - name: kubeconfig
            #   mountPath: /etc/fluxd/kube
    
            # Include this to point kubectl at a different config; you
            # will need to do this if you have mounted an alternate config
            # from a configmap, as in commented blocks above.
            # env:
            # - name: KUBECONFIG
            #   value: /etc/fluxd/kube/config
    
            # Include this and the volume "gpg-keys" above, and the
            # args below.
            # - name: gpg-keys
            #   mountPath: /root/gpg-import
            #   readOnly: true
    
            # Include this if you want to supply HTTP basic auth credentials for git
            # via the `GIT_AUTHUSER` and `GIT_AUTHKEY` environment variables using a
            # secret.
            # envFrom:
            # - secretRef:
            #     name: flux-git-auth
    
            args:
    
            # Include these two to enable git commit signing
            # - --git-gpg-key-import=/root/gpg-import
            # - --git-signing-key=<key id>
            
            # Include this to enable git signature verification
            # - --git-verify-signatures
    
            # Tell flux it has readonly access to the repo (default `false`)
            # - --git-readonly
    
            # Instruct flux where to put sync bookkeeping (default "git", meaning use a tag in the upstream git repo)
            # - --sync-state=git
    
            # Include these next two to connect to an "upstream" service
            # (e.g., Weave Cloud). The token is particular to the service.
            # - --connect=wss://cloud.weave.works/api/flux
            # - --token=abc123abc123abc123abc123
    
            # Enable manifest generation (default `false`)
            # - --manifest-generation=false
    
            # Serve /metrics endpoint at different port;
            # make sure to set prometheus' annotation to scrape the port value.
            - --listen-metrics=:3031
