---
# kubectl create secret generic tidbcloud-credentials -n test-infra --dry-run=client --from-file=credentials=~/.aws/staging.credentials -oyaml
apiVersion: v1
data:
    credentials: ""
kind: Secret
metadata:
    creationTimestamp: null
    name: tidbcloud-credentials
    namespace: test-infra
---
# kubectl create secret generic tidbcloud-kubeconfig -n test-infra --dry-run=client --from-file=config=~/.kube/staging.config -oyaml
apiVersion: v1
data:
    config: ""
kind: Secret
metadata:
    creationTimestamp: null
    name: tidbcloud-kubeconfig
    namespace: test-infra
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tidbcloud-kubectl-proxy
  namespace: test-infra
spec:
  selector:
    matchLabels:
      app: tidbcloud-kubectl-proxy
  replicas: 2
  template:
    metadata:
      annotations:
        app.kubernetes.io/managed-by: test-infra
      labels:
        app: tidbcloud-kubectl-proxy
    spec:
      containers:
        - name: kubectl
          command: [kubectl]
          args:
            - proxy
            - --address
            - 0.0.0.0
            - --accept-hosts
            - '.*'
          image: 'mahjonp/kubectl-proxy'
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 8001
          resources:
            requests:
              cpu: 500m
              memory: 2000Mi
            limits:
              cpu: 500m
              memory: 2000Mi
          volumeMounts:
            - name: credentials
              mountPath: /root/.aws
              readOnly: true
            - name: kubeconfig
              mountPath: /root/.kube
              readOnly: true
      volumes:
        - name: credentials
          secret:
            secretName: tidbcloud-credentials
            optional: false
        - name: kubeconfig
          secret:
              secretName: tidbcloud-kubeconfig
              optional: false
      terminationGracePeriodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
  name: tidbcloud-kubectl-proxy-service
  namespace: test-infra
spec:
  type: ClusterIP
  selector:
    app: tidbcloud-kubectl-proxy
  ports:
    - protocol: TCP
      port: 8001
      targetPort: 8001
