github.com/qsunny/k8s@v0.0.0-20220101153623-e6dca256d5bf/examples-master/staging/cockroachdb/minikube.sh (about) 1 #!/usr/bin/env 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 # Run the CockroachDB StatefulSet example on a minikube instance. 18 # 19 # For a fresh start, run the following first: 20 # minikube delete 21 # minikube start 22 # 23 # To upgrade minikube & kubectl on OSX, the following should suffice: 24 # brew reinstall kubernetes-cli --devel 25 # url -Lo minikube \ 26 # https://storage.googleapis.com/minikube/releases/v0.4.0/minikube-darwin-amd64 && \ 27 # chmod +x minikube && sudo mv minikube /usr/local/bin/ 28 29 set -exuo pipefail 30 31 # Clean up anything from a prior run: 32 kubectl delete statefulsets,persistentvolumes,persistentvolumeclaims,services,poddisruptionbudget -l app=cockroachdb 33 34 # Make persistent volumes and (correctly named) claims. We must create the 35 # claims here manually even though that sounds counter-intuitive. For details 36 # see https://github.com/kubernetes/contrib/pull/1295#issuecomment-230180894. 37 # Note that we make an extra volume here so you can manually test scale-up. 38 for i in $(seq 0 3); do 39 cat <<EOF | kubectl create -f - 40 kind: PersistentVolume 41 apiVersion: v1 42 metadata: 43 name: pv${i} 44 labels: 45 type: local 46 app: cockroachdb 47 spec: 48 capacity: 49 storage: 1Gi 50 accessModes: 51 - ReadWriteOnce 52 hostPath: 53 path: "/tmp/${i}" 54 EOF 55 56 cat <<EOF | kubectl create -f - 57 kind: PersistentVolumeClaim 58 apiVersion: v1 59 metadata: 60 name: datadir-cockroachdb-${i} 61 labels: 62 app: cockroachdb 63 spec: 64 accessModes: 65 - ReadWriteOnce 66 resources: 67 requests: 68 storage: 1Gi 69 EOF 70 done; 71 72 kubectl create -f cockroachdb-statefulset.yaml