github.com/vipernet-xyz/tm@v0.34.24/tools/mintnet-kubernetes/examples/dummy/app.yaml (about) 1 --- 2 apiVersion: v1 3 kind: Service 4 metadata: 5 annotations: 6 service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" 7 name: dummy 8 labels: 9 app: dummy 10 spec: 11 ports: 12 - port: 26656 13 name: p2p 14 - port: 26657 15 name: rpc 16 clusterIP: None 17 selector: 18 app: tm 19 --- 20 apiVersion: v1 21 kind: ConfigMap 22 metadata: 23 name: tm-config 24 data: 25 seeds: "tm-0,tm-1,tm-2,tm-3" 26 validators: "tm-0,tm-1,tm-2,tm-3" 27 validator.power: "10" 28 genesis.json: |- 29 { 30 "genesis_time": "2016-02-05T23:17:31.164Z", 31 "chain_id": "chain-B5XXm5", 32 "validators": [], 33 "app_hash": "" 34 } 35 pub_key_nginx.conf: |- 36 server { 37 listen 80 default_server; 38 listen [::]:80 default_server ipv6only=on; 39 location /pub_key.json { root /usr/share/nginx/; } 40 } 41 --- 42 apiVersion: policy/v1beta1 43 kind: PodDisruptionBudget 44 metadata: 45 name: tm-budget 46 spec: 47 selector: 48 matchLabels: 49 app: tm 50 minAvailable: 2 51 --- 52 apiVersion: apps/v1beta1 53 kind: StatefulSet 54 metadata: 55 name: tm 56 spec: 57 serviceName: dummy 58 replicas: 4 59 template: 60 metadata: 61 labels: 62 app: tm 63 annotations: 64 pod.beta.kubernetes.io/init-containers: '[{ 65 "name": "tm-gen-validator", 66 "image": "tendermint/tendermint:0.10.0", 67 "imagePullPolicy": "IfNotPresent", 68 "command": ["bash", "-c", " 69 set -ex\n 70 if [ ! -f /tendermint/priv_validator.json ]; then\n 71 tendermint gen_validator > /tendermint/priv_validator.json\n 72 # pub_key.json will be served by pub-key container\n 73 cat /tendermint/priv_validator.json | jq \".pub_key\" > /tendermint/pub_key.json\n 74 fi\n 75 "], 76 "volumeMounts": [ 77 {"name": "tmdir", "mountPath": "/tendermint"} 78 ] 79 }]' 80 spec: 81 containers: 82 - name: tm 83 imagePullPolicy: IfNotPresent 84 image: tendermint/tendermint:0.10.0 85 ports: 86 - containerPort: 26656 87 name: p2p 88 - containerPort: 26657 89 name: rpc 90 env: 91 - name: SEEDS 92 valueFrom: 93 configMapKeyRef: 94 name: tm-config 95 key: seeds 96 - name: VALIDATOR_POWER 97 valueFrom: 98 configMapKeyRef: 99 name: tm-config 100 key: validator.power 101 - name: VALIDATORS 102 valueFrom: 103 configMapKeyRef: 104 name: tm-config 105 key: validators 106 - name: TMHOME 107 value: /tendermint 108 command: 109 - bash 110 - "-c" 111 - | 112 set -ex 113 114 # copy template 115 cp /etc/tendermint/genesis.json /tendermint/genesis.json 116 117 # fill genesis file with validators 118 IFS=',' read -ra VALS_ARR <<< "$VALIDATORS" 119 fqdn_suffix=$(hostname -f | sed 's#[^.]*\.\(\)#\1#') 120 for v in "${VALS_ARR[@]}"; do 121 # wait until validator generates priv/pub key pair 122 set +e 123 124 curl -s --fail "http://$v.$fqdn_suffix/pub_key.json" > /dev/null 125 ERR=$? 126 while [ "$ERR" != 0 ]; do 127 sleep 5 128 curl -s --fail "http://$v.$fqdn_suffix/pub_key.json" > /dev/null 129 ERR=$? 130 done 131 set -e 132 133 # add validator to genesis file along with its pub_key 134 curl -s "http://$v.$fqdn_suffix/pub_key.json" | jq ". as \$k | {pub_key: \$k, amount: $VALIDATOR_POWER, name: \"$v\"}" > pub_validator.json 135 cat /tendermint/genesis.json | jq ".validators |= .+ [$(cat pub_validator.json)]" > tmpgenesis && mv tmpgenesis /tendermint/genesis.json 136 rm pub_validator.json 137 done 138 139 # construct seeds 140 IFS=',' read -ra SEEDS_ARR <<< "$SEEDS" 141 seeds=() 142 for s in "${SEEDS_ARR[@]}"; do 143 seeds+=("$s.$fqdn_suffix:26656") 144 done 145 seeds=$(IFS=','; echo "${seeds[*]}") 146 147 tendermint node --p2p.seeds="$seeds" --moniker="`hostname`" --proxy_app="dummy" 148 volumeMounts: 149 - name: tmdir 150 mountPath: /tendermint 151 - mountPath: /etc/tendermint/genesis.json 152 name: tmconfigdir 153 subPath: genesis.json 154 - name: socksdir 155 mountPath: /socks 156 157 - name: pub-key 158 imagePullPolicy: IfNotPresent 159 image: nginx:latest 160 ports: 161 - containerPort: 80 162 name: pub-key 163 command: 164 - bash 165 - "-c" 166 - | 167 set -ex 168 # fixes 403 Permission Denied (open() "/tendermint/pub_key.json" failed (13: Permission denied)) 169 # => we cannot serve from /tendermint, so we copy the file 170 mkdir -p /usr/share/nginx 171 cp /tendermint/pub_key.json /usr/share/nginx/pub_key.json 172 nginx -g "daemon off;" 173 volumeMounts: 174 - name: tmdir 175 mountPath: /tendermint 176 - mountPath: /etc/nginx/conf.d/pub_key.conf 177 name: tmconfigdir 178 subPath: pub_key_nginx.conf 179 180 volumes: 181 - name: tmconfigdir 182 configMap: 183 name: tm-config 184 - name: socksdir 185 emptyDir: {} 186 187 volumeClaimTemplates: 188 - metadata: 189 name: tmdir 190 annotations: 191 volume.alpha.kubernetes.io/storage-class: anything 192 spec: 193 accessModes: ["ReadWriteOnce"] 194 resources: 195 requests: 196 storage: 2Gi