github.com/abayer/test-infra@v0.0.5/mungegithub/issue_labeler/deploy.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2016 The Kubernetes Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  set -e
    18  
    19  kubectl apply -f - <<EOF
    20  apiVersion: v1
    21  kind: PersistentVolume
    22  metadata:
    23    labels:
    24      app: machine-learning-app
    25    name: machine-learning-volume
    26  spec:
    27    capacity:
    28      storage: 10Gi
    29    accessModes:
    30      - ReadWriteOnce
    31    persistentVolumeReclaimPolicy: Retain
    32    gcePersistentDisk:
    33      pdName: machine-learning-volume
    34      fsType: ext4
    35  EOF
    36  
    37  kubectl apply -f - <<EOF
    38  kind: PersistentVolumeClaim
    39  apiVersion: v1
    40  metadata:
    41    name: machine-learning-volume-claim
    42  spec:
    43    accessModes:
    44      - ReadWriteOnce
    45    resources:
    46      requests:
    47        storage: 10Gi
    48    storageClassName: standard
    49    volumeName: machine-learning-volume
    50  EOF
    51  
    52  ! test -z "$(gcloud compute disks list --uri machine-learning-volume)" || \
    53  	    gcloud compute disks create machine-learning-volume --size 10GB
    54  
    55  IMAGE=${1:-gcr.io/k8s-testimages/issue-triager:latest}
    56  docker build --pull -t "$IMAGE" -f Dockerfile . 
    57  docker push "$IMAGE"
    58  
    59  kubectl apply -f - <<EOF
    60  apiVersion: extensions/v1beta1
    61  kind: Deployment
    62  metadata:
    63    name: issue-triager
    64  spec:
    65    replicas: 1
    66    template:
    67      metadata:
    68        labels:
    69          app: issue-triager
    70      spec:
    71        containers:
    72        - name: issue-triager
    73          command: ["python", "simple_app.py"]
    74          image: $IMAGE
    75          ports:
    76          - name: ml-port
    77            containerPort: 5000
    78          volumeMounts:
    79          - mountPath: /models/
    80            name: database-volume
    81        volumes:
    82        - name: database-volume
    83          persistentVolumeClaim:
    84            claimName: machine-learning-volume-claim
    85  EOF
    86  
    87  kubectl apply -f - <<EOF
    88  apiVersion: v1
    89  kind: Service
    90  metadata:
    91    labels:
    92      app: issue-triager
    93    name: issue-triager-service
    94    namespace: default
    95  spec:
    96    ports:
    97    - name: ml-port
    98      port: 5000
    99      targetPort: ml-port
   100    selector:
   101      app: issue-triager
   102  EOF