github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/k8s/testyaml/testyaml.go (about) 1 package testyaml 2 3 import ( 4 "strings" 5 ) 6 7 const BlorgBackendYAML = ` 8 apiVersion: v1 9 kind: Service 10 metadata: 11 name: devel-nick-lb-blorg-be 12 labels: 13 app: blorg 14 owner: nick 15 environment: devel 16 tier: backend 17 spec: 18 type: LoadBalancer 19 ports: 20 - port: 8080 21 targetPort: 8080 22 selector: 23 app: blorg 24 owner: nick 25 environment: devel 26 tier: backend 27 --- 28 apiVersion: extensions/v1beta1 29 kind: Deployment 30 metadata: 31 name: devel-nick-blorg-be 32 spec: 33 selector: 34 matchLabels: 35 app: blorg 36 owner: nick 37 environment: devel 38 tier: backend 39 template: 40 metadata: 41 name: devel-nick-blorg-be 42 labels: 43 app: blorg 44 owner: nick 45 environment: devel 46 tier: backend 47 spec: 48 containers: 49 - name: backend 50 imagePullPolicy: Always 51 image: gcr.io/blorg-dev/blorg-backend:devel-nick 52 command: [ 53 "/app/server", 54 "--dbAddr", "hissing-cockroach-cockroachdb:26257" 55 ] 56 ports: 57 - containerPort: 8080 58 ` 59 60 const BlorgBackendAmbiguousYAML = ` 61 apiVersion: v1 62 kind: Service 63 metadata: 64 name: blorg 65 labels: 66 app: blorg 67 owner: nick 68 environment: devel 69 tier: backend 70 spec: 71 type: LoadBalancer 72 ports: 73 - port: 8080 74 targetPort: 8080 75 selector: 76 app: blorg 77 owner: nick 78 environment: devel 79 tier: backend 80 --- 81 apiVersion: extensions/v1beta1 82 kind: Deployment 83 metadata: 84 name: blorg 85 spec: 86 selector: 87 matchLabels: 88 app: blorg 89 owner: nick 90 environment: devel 91 tier: backend 92 template: 93 metadata: 94 name: blorg 95 labels: 96 app: blorg 97 owner: nick 98 environment: devel 99 tier: backend 100 spec: 101 containers: 102 - name: backend 103 imagePullPolicy: Always 104 image: gcr.io/blorg-dev/blorg 105 command: [ 106 "/app/server", 107 "--dbAddr", "hissing-cockroach-cockroachdb:26257" 108 ] 109 ports: 110 - containerPort: 8080 111 ` 112 113 const BlorgJobYAML = `apiVersion: batch/v1 114 kind: Job 115 metadata: 116 name: blorg-job 117 spec: 118 template: 119 spec: 120 containers: 121 - name: blorg-job 122 image: gcr.io/blorg-dev/blorg-backend:devel-nick 123 command: ["/app/server", "-job=clean"] 124 restartPolicy: Never 125 backoffLimit: 4 126 ` 127 128 const SanchoImage = "gcr.io/some-project-162817/sancho" 129 130 const SanchoYAML = ` 131 apiVersion: apps/v1 132 kind: Deployment 133 metadata: 134 name: sancho 135 labels: 136 app: sancho 137 spec: 138 replicas: 1 139 selector: 140 matchLabels: 141 app: sancho 142 template: 143 metadata: 144 labels: 145 app: sancho 146 spec: 147 containers: 148 - name: sancho 149 image: gcr.io/some-project-162817/sancho 150 env: 151 - name: token 152 valueFrom: 153 secretKeyRef: 154 name: slacktoken 155 key: token 156 ` 157 158 const SanchoTwoContainersOneImageYAML = ` 159 apiVersion: apps/v1 160 kind: Deployment 161 metadata: 162 name: sancho-2c1i 163 namespace: sancho-ns 164 labels: 165 app: sancho-2c1i 166 spec: 167 replicas: 1 168 selector: 169 matchLabels: 170 app: sancho-2c1i 171 template: 172 metadata: 173 labels: 174 app: sancho-2c1i 175 spec: 176 containers: 177 - name: sancho 178 image: gcr.io/some-project-162817/sancho 179 - name: sancho2 180 image: gcr.io/some-project-162817/sancho 181 ` 182 183 const SanchoYAMLWithCommand = ` 184 apiVersion: apps/v1 185 kind: Deployment 186 metadata: 187 name: sancho 188 namespace: sancho-ns 189 labels: 190 app: sancho 191 spec: 192 replicas: 1 193 selector: 194 matchLabels: 195 app: sancho 196 template: 197 metadata: 198 labels: 199 app: sancho 200 spec: 201 containers: 202 - name: sancho 203 image: gcr.io/some-project-162817/sancho 204 command: ["foo.sh"] 205 args: ["something", "something_else"] 206 ` 207 208 const SanchoBeta1YAML = ` 209 apiVersion: apps/v1beta1 210 kind: Deployment 211 metadata: 212 name: sancho 213 namespace: sancho-ns 214 labels: 215 app: sancho 216 spec: 217 replicas: 1 218 template: 219 metadata: 220 labels: 221 app: sancho 222 spec: 223 containers: 224 - name: sancho 225 image: gcr.io/some-project-162817/sancho 226 env: 227 - name: token 228 valueFrom: 229 secretKeyRef: 230 name: slacktoken 231 key: token 232 ` 233 234 const SanchoStatefulSetBeta1YAML = ` 235 apiVersion: apps/v1beta1 236 kind: StatefulSet 237 metadata: 238 name: sancho 239 namespace: sancho-ns 240 labels: 241 app: sancho 242 spec: 243 replicas: 1 244 template: 245 metadata: 246 labels: 247 app: sancho 248 spec: 249 containers: 250 - name: sancho 251 image: gcr.io/some-project-162817/sancho 252 ` 253 254 const SanchoBeta2YAML = ` 255 apiVersion: apps/v1beta2 256 kind: Deployment 257 metadata: 258 name: sancho 259 namespace: sancho-ns 260 labels: 261 app: sancho 262 spec: 263 replicas: 1 264 template: 265 metadata: 266 labels: 267 app: sancho 268 spec: 269 containers: 270 - name: sancho 271 image: gcr.io/some-project-162817/sancho 272 env: 273 - name: token 274 valueFrom: 275 secretKeyRef: 276 name: slacktoken 277 key: token 278 ` 279 280 const SanchoExtBeta1YAML = ` 281 apiVersion: extensions/v1beta1 282 kind: Deployment 283 metadata: 284 name: sancho 285 namespace: sancho-ns 286 labels: 287 app: sancho 288 spec: 289 replicas: 1 290 template: 291 metadata: 292 labels: 293 app: sancho 294 spec: 295 containers: 296 - name: sancho 297 image: gcr.io/some-project-162817/sancho 298 env: 299 - name: token 300 valueFrom: 301 secretKeyRef: 302 name: slacktoken 303 key: token 304 ` 305 306 const SanchoTwinYAML = ` 307 apiVersion: apps/v1 308 kind: Deployment 309 metadata: 310 name: sancho-twin 311 namespace: sancho-ns 312 labels: 313 app: sancho-twin 314 spec: 315 replicas: 1 316 selector: 317 matchLabels: 318 app: sancho-twin 319 template: 320 metadata: 321 labels: 322 app: sancho-twin 323 spec: 324 containers: 325 - name: sancho 326 image: gcr.io/some-project-162817/sancho 327 env: 328 - name: token 329 valueFrom: 330 secretKeyRef: 331 name: slacktoken 332 key: token 333 ` 334 335 const SanchoSidecarYAML = ` 336 apiVersion: apps/v1 337 kind: Deployment 338 metadata: 339 name: sancho 340 namespace: sancho-ns 341 labels: 342 app: sancho 343 spec: 344 replicas: 1 345 selector: 346 matchLabels: 347 app: sancho 348 template: 349 metadata: 350 labels: 351 app: sancho 352 spec: 353 containers: 354 - name: sancho 355 image: gcr.io/some-project-162817/sancho 356 env: 357 - name: token 358 valueFrom: 359 secretKeyRef: 360 name: slacktoken 361 key: token 362 - name: sancho-sidecar 363 image: gcr.io/some-project-162817/sancho-sidecar 364 ` 365 const SanchoSidecarImage = "gcr.io/some-project-162817/sancho-sidecar" 366 367 const SanchoRedisSidecarYAML = ` 368 apiVersion: apps/v1 369 kind: Deployment 370 metadata: 371 name: sancho 372 namespace: sancho-ns 373 labels: 374 app: sancho 375 spec: 376 replicas: 1 377 selector: 378 matchLabels: 379 app: sancho 380 template: 381 metadata: 382 labels: 383 app: sancho 384 spec: 385 containers: 386 - name: sancho 387 image: gcr.io/some-project-162817/sancho 388 env: 389 - name: token 390 valueFrom: 391 secretKeyRef: 392 name: slacktoken 393 key: token 394 - name: redis-sidecar 395 image: redis:latest 396 ` 397 398 const SanchoImageInEnvYAML = ` 399 apiVersion: apps/v1 400 kind: Deployment 401 metadata: 402 name: sancho 403 namespace: sancho-ns 404 labels: 405 app: sancho 406 spec: 407 replicas: 1 408 selector: 409 matchLabels: 410 app: sancho 411 template: 412 metadata: 413 labels: 414 app: sancho 415 spec: 416 containers: 417 - name: sancho 418 image: gcr.io/some-project-162817/sancho 419 env: 420 - name: foo 421 value: gcr.io/some-project-162817/sancho2 422 - name: bar 423 value: gcr.io/some-project-162817/sancho 424 ` 425 426 const TracerYAML = ` 427 apiVersion: extensions/v1beta1 428 kind: Deployment 429 metadata: 430 name: tracer-prod 431 spec: 432 replicas: 1 433 revisionHistoryLimit: 2 434 template: 435 metadata: 436 labels: 437 app: tracer 438 track: prod 439 spec: 440 nodeSelector: 441 cloud.google.com/gke-nodepool: default-pool 442 443 containers: 444 - name: tracer 445 image: openzipkin/zipkin 446 ports: 447 - name: http 448 containerPort: 9411 449 livenessProbe: 450 httpGet: 451 path: / 452 port: 9411 453 initialDelaySeconds: 60 454 periodSeconds: 60 455 readinessProbe: 456 httpGet: 457 path: / 458 port: 9411 459 initialDelaySeconds: 30 460 periodSeconds: 1 461 timeoutSeconds: 1 462 successThreshold: 1 463 failureThreshold: 10 464 --- 465 apiVersion: v1 466 kind: Service 467 metadata: 468 name: tracer-prod 469 labels: 470 app: tracer 471 track: prod 472 spec: 473 selector: 474 app: tracer 475 track: prod 476 type: ClusterIP 477 ports: 478 - protocol: TCP 479 port: 80 480 targetPort: http 481 --- 482 apiVersion: v1 483 kind: Service 484 metadata: 485 name: tracer-lb-prod 486 labels: 487 app: tracer 488 track: prod 489 spec: 490 selector: 491 app: tracer 492 track: prod 493 type: LoadBalancer 494 ports: 495 - protocol: TCP 496 port: 80 497 targetPort: http 498 ` 499 500 const JobYAML = ` 501 apiVersion: batch/v1 502 kind: Job 503 metadata: 504 name: pi 505 spec: 506 template: 507 spec: 508 containers: 509 - name: pi 510 image: perl 511 command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] 512 restartPolicy: Never 513 backoffLimit: 4 514 ` 515 516 const PodYAML = `apiVersion: v1 517 kind: Pod 518 metadata: 519 name: sleep 520 labels: 521 app: sleep 522 spec: 523 restartPolicy: OnFailure 524 containers: 525 - name: sleep 526 image: gcr.io/windmill-public-containers/servantes/sleep 527 ` 528 529 const MultipleContainersYAML = ` 530 apiVersion: batch/v1 531 kind: Job 532 metadata: 533 name: pi 534 spec: 535 template: 536 spec: 537 containers: 538 - name: pi1 539 image: gcr.io/blorg-dev/perl 540 command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] 541 - name: pi2 542 image: gcr.io/blorg-dev/perl 543 command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] 544 restartPolicy: Never 545 backoffLimit: 4 546 ` 547 548 const MultipleContainersDeploymentYAML = `apiVersion: apps/v1 549 kind: Deployment 550 metadata: 551 name: test-deployment 552 spec: 553 replicas: 1 554 template: 555 spec: 556 containers: 557 - name: client 558 image: dockerhub.io/client:0.1.0-dev 559 imagePullPolicy: Always 560 ports: 561 - name: http-client 562 containerPort: 9000 563 protocol: TCP 564 - name: backend 565 image: dockerhub.io/backend:0.1.0-dev 566 imagePullPolicy: Always 567 ports: 568 - name: http-backend 569 containerPort: 8000 570 protocol: TCP 571 volumeMounts: 572 - name: config 573 mountPath: /etc/backend 574 readOnly: true 575 volumes: 576 - name: config 577 configMap: 578 name: fe-backend 579 items: 580 - key: config 581 path: config.yaml` 582 583 const SyncletYAML = `apiVersion: apps/v1beta2 584 kind: DaemonSet 585 metadata: 586 name: owner-synclet 587 namespace: kube-system 588 labels: 589 app: synclet 590 owner: owner 591 environment: dev 592 spec: 593 selector: 594 matchLabels: 595 app: synclet 596 owner: owner 597 environment: dev 598 template: 599 metadata: 600 labels: 601 app: synclet 602 owner: owner 603 environment: dev 604 spec: 605 tolerations: 606 - key: node-role.kubernetes.io/master 607 effect: NoSchedule 608 containers: 609 - name: synclet 610 image: gcr.io/windmill-public-containers/synclet 611 imagePullPolicy: Always 612 volumeMounts: 613 - name: dockersocker 614 mountPath: /var/run/docker.sock 615 securityContext: 616 privileged: true 617 - image: jaegertracing/jaeger-agent 618 name: jaeger-agent 619 ports: 620 - containerPort: 5775 621 protocol: UDP 622 - containerPort: 6831 623 protocol: UDP 624 - containerPort: 6832 625 protocol: UDP 626 - containerPort: 5778 627 protocol: TCP 628 args: ["--collector.host-port=jaeger-collector.default:14267"] 629 volumes: 630 - name: dockersocker 631 hostPath: 632 path: /var/run/docker.sock 633 ` 634 635 // We deliberately create a pod without any labels, to 636 // ensure code works without them. 637 const LonelyPodYAML = ` 638 apiVersion: v1 639 kind: Pod 640 metadata: 641 name: lonely-pod 642 spec: 643 containers: 644 - name: lonely-pod 645 image: gcr.io/windmill-public-containers/lonely-pod 646 imagePullPolicy: Always 647 command: ["/go/bin/lonely-pod"] 648 ports: 649 - containerPort: 8001 650 ` 651 652 // Useful if you ever want to play around with 653 // deploying postgres 654 const PostgresYAML = ` 655 apiVersion: v1 656 kind: ConfigMap 657 metadata: 658 name: postgres-config 659 labels: 660 app: postgres 661 data: 662 POSTGRES_DB: postgresdb 663 POSTGRES_USER: postgresadmin 664 POSTGRES_PASSWORD: admin123 665 --- 666 kind: PersistentVolume 667 apiVersion: v1 668 metadata: 669 name: postgres-pv-volume 670 labels: 671 type: local 672 app: postgres 673 spec: 674 storageClassName: manual 675 capacity: 676 storage: 5Gi 677 accessModes: 678 - ReadWriteMany 679 hostPath: 680 path: "/mnt/data" 681 --- 682 kind: PersistentVolumeClaim 683 apiVersion: v1 684 metadata: 685 name: postgres-pv-claim 686 labels: 687 app: postgres 688 spec: 689 storageClassName: manual 690 accessModes: 691 - ReadWriteMany 692 resources: 693 requests: 694 storage: 1Gi 695 --- 696 apiVersion: apps/v1 697 kind: StatefulSet 698 metadata: 699 name: postgres 700 spec: 701 serviceName: postgres 702 replicas: 3 703 selector: 704 matchLabels: 705 app: postgres 706 template: 707 metadata: 708 labels: 709 app: postgres 710 selector: 711 spec: 712 updateStrategy: 713 type: RollingUpdate 714 containers: 715 - name: postgres 716 image: postgres:10.4 717 imagePullPolicy: "IfNotPresent" 718 ports: 719 - containerPort: 5432 720 envFrom: 721 - configMapRef: 722 name: postgres-config 723 volumeMounts: 724 - mountPath: /var/lib/postgresql/data 725 name: postgredb 726 volumes: 727 - name: postgredb 728 persistentVolumeClaim: 729 claimName: postgres-pv-claim 730 --- 731 apiVersion: v1 732 kind: Service 733 metadata: 734 name: postgres 735 labels: 736 app: postgres 737 spec: 738 type: NodePort 739 ports: 740 - port: 5432 741 selector: 742 app: postgres 743 ` 744 745 // Requires significant sorting to get to an order that's "safe" for applying (see kustomize/ordering.go) 746 const OutOfOrderYaml = ` 747 apiVersion: batch/v1 748 kind: Job 749 metadata: 750 name: blorg-job 751 spec: 752 template: 753 spec: 754 containers: 755 - name: blorg-job 756 image: gcr.io/blorg-dev/blorg-backend:devel-nick 757 command: ["/app/server", "-job=clean"] 758 restartPolicy: Never 759 backoffLimit: 4 760 --- 761 kind: PersistentVolumeClaim 762 apiVersion: v1 763 metadata: 764 name: postgres-pv-claim 765 labels: 766 app: postgres 767 spec: 768 storageClassName: manual 769 accessModes: 770 - ReadWriteMany 771 resources: 772 requests: 773 storage: 1Gi 774 --- 775 apiVersion: v1 776 kind: Service 777 metadata: 778 name: postgres 779 labels: 780 app: postgres 781 spec: 782 type: NodePort 783 ports: 784 - port: 5432 785 selector: 786 app: postgres 787 --- 788 apiVersion: v1 789 kind: Pod 790 metadata: 791 name: sleep 792 labels: 793 app: sleep 794 spec: 795 restartPolicy: OnFailure 796 containers: 797 - name: sleep 798 image: gcr.io/windmill-public-containers/servantes/sleep 799 --- 800 apiVersion: v1 801 kind: ConfigMap 802 metadata: 803 name: postgres-config 804 labels: 805 app: postgres 806 data: 807 POSTGRES_DB: postgresdb 808 POSTGRES_USER: postgresadmin 809 POSTGRES_PASSWORD: admin123 810 --- 811 kind: PersistentVolume 812 apiVersion: v1 813 metadata: 814 name: postgres-pv-volume 815 labels: 816 type: local 817 app: postgres 818 spec: 819 storageClassName: manual 820 capacity: 821 storage: 5Gi 822 accessModes: 823 - ReadWriteMany 824 hostPath: 825 path: "/mnt/data" 826 --- 827 828 apiVersion: apps/v1 829 kind: StatefulSet 830 metadata: 831 name: postgres 832 spec: 833 serviceName: postgres 834 replicas: 3 835 selector: 836 matchLabels: 837 app: postgres 838 template: 839 metadata: 840 labels: 841 app: postgres 842 selector: 843 spec: 844 updateStrategy: 845 type: RollingUpdate 846 containers: 847 - name: postgres 848 image: postgres:10.4 849 imagePullPolicy: "IfNotPresent" 850 ports: 851 - containerPort: 5432 852 envFrom: 853 - configMapRef: 854 name: postgres-config 855 volumeMounts: 856 - mountPath: /var/lib/postgresql/data 857 name: postgredb 858 volumes: 859 - name: postgredb 860 persistentVolumeClaim: 861 claimName: postgres-pv-claim 862 863 ` 864 865 const DoggosDeploymentYaml = ` 866 apiVersion: apps/v1 867 kind: Deployment 868 metadata: 869 name: doggos 870 labels: 871 app: doggos 872 breed: corgi 873 whosAGoodBoy: imAGoodBoy 874 namespace: the-dog-zone 875 spec: 876 selector: 877 matchLabels: 878 app: doggos 879 breed: corgi 880 whosAGoodBoy: imAGoodBoy 881 template: 882 metadata: 883 labels: 884 app: doggos 885 breed: corgi 886 whosAGoodBoy: imAGoodBoy 887 tier: web 888 spec: 889 containers: 890 - name: doggos 891 image: gcr.io/windmill-public-containers/servantes/doggos 892 command: ["/go/bin/doggos"] 893 ` 894 895 const DoggosServiceYaml = ` 896 apiVersion: v1 897 kind: Service 898 metadata: 899 name: doggos 900 labels: 901 app: doggos 902 whosAGoodBoy: imAGoodBoy 903 spec: 904 ports: 905 - port: 80 906 targetPort: 8083 907 protocol: TCP 908 selector: 909 app: doggos 910 ` 911 const CatsServiceYaml = ` 912 apiVersion: v1 913 kind: Service 914 metadata: 915 name: cats 916 labels: 917 app: cats 918 whosAGoodCat: meow 919 spec: 920 ports: 921 - port: 60 922 targetPort: 6083 923 protocol: TCP 924 selector: 925 app: cats 926 ` 927 928 const ( 929 DoggosName = "doggos" 930 DoggosNamespace = "the-dog-zone" 931 ) 932 933 const SnackYaml = ` 934 apiVersion: apps/v1 935 kind: Deployment 936 metadata: 937 name: snack 938 labels: 939 app: snack 940 spec: 941 selector: 942 matchLabels: 943 app: snack 944 template: 945 metadata: 946 labels: 947 app: snack 948 spec: 949 containers: 950 - name: snack 951 image: gcr.io/windmill-public-containers/servantes/snack 952 command: ["/go/bin/snack"] 953 ` 954 const ( 955 SnackName = "snack" 956 SnackImage = "gcr.io/windmill-public-containers/servantes/snack" 957 ) 958 959 const SnackYAMLPostConfig = `apiVersion: apps/v1 960 kind: Deployment 961 metadata: 962 labels: 963 app: snack 964 name: snack 965 spec: 966 selector: 967 matchLabels: 968 app: snack 969 strategy: {} 970 template: 971 metadata: 972 labels: 973 app: snack 974 spec: 975 containers: 976 - command: 977 - /go/bin/snack 978 image: gcr.io/windmill-public-containers/servantes/snack 979 name: snack 980 resources: {} 981 ` 982 983 const SecretName = "mysecret" 984 const SecretYaml = ` 985 apiVersion: v1 986 kind: Secret 987 metadata: 988 name: mysecret 989 type: Opaque 990 data: 991 username: YWRtaW4= 992 password: MWYyZDFlMmU2N2Rm 993 ` 994 995 // Generated with 996 // helm fetch stable/redis --version 5.1.3 --untar --untardir tmp && helm template tmp/redis --name test 997 const HelmGeneratedRedisYAML = ` 998 --- 999 # Source: redis/templates/secret.yaml 1000 apiVersion: v1 1001 kind: Secret 1002 metadata: 1003 name: test-redis 1004 labels: 1005 app: redis 1006 chart: redis-5.1.3 1007 release: "test" 1008 heritage: "Tiller" 1009 type: Opaque 1010 data: 1011 redis-password: "VnF0bkFrUks0cg==" 1012 --- 1013 # Source: redis/templates/configmap.yaml 1014 apiVersion: v1 1015 kind: ConfigMap 1016 metadata: 1017 labels: 1018 app: redis 1019 chart: redis-5.1.3 1020 heritage: Tiller 1021 release: test 1022 name: test-redis 1023 data: 1024 redis.conf: |- 1025 # User-supplied configuration: 1026 # maxmemory-policy volatile-lru 1027 master.conf: |- 1028 dir /data 1029 rename-command FLUSHDB "" 1030 rename-command FLUSHALL "" 1031 replica.conf: |- 1032 dir /data 1033 rename-command FLUSHDB "" 1034 rename-command FLUSHALL "" 1035 1036 --- 1037 # Source: redis/templates/health-configmap.yaml 1038 apiVersion: v1 1039 kind: ConfigMap 1040 metadata: 1041 labels: 1042 app: redis 1043 chart: redis-5.1.3 1044 heritage: Tiller 1045 release: test 1046 name: test-redis-health 1047 data: 1048 ping_local.sh: |- 1049 response=$( 1050 redis-cli \ 1051 -a $REDIS_PASSWORD \ 1052 -h localhost \ 1053 -p $REDIS_PORT \ 1054 ping 1055 ) 1056 if [ "$response" != "PONG" ]; then 1057 echo "$response" 1058 exit 1 1059 fi 1060 ping_master.sh: |- 1061 response=$( 1062 redis-cli \ 1063 -a $REDIS_MASTER_PASSWORD \ 1064 -h $REDIS_MASTER_HOST \ 1065 -p $REDIS_MASTER_PORT_NUMBER \ 1066 ping 1067 ) 1068 if [ "$response" != "PONG" ]; then 1069 echo "$response" 1070 exit 1 1071 fi 1072 ping_local_and_master.sh: |- 1073 script_dir="$(dirname "$0")" 1074 exit_status=0 1075 "$script_dir/ping_local.sh" || exit_status=$? 1076 "$script_dir/ping_master.sh" || exit_status=$? 1077 exit $exit_status 1078 1079 --- 1080 # Source: redis/templates/redis-master-svc.yaml 1081 apiVersion: v1 1082 kind: Service 1083 metadata: 1084 name: test-redis-master 1085 labels: 1086 app: redis 1087 chart: redis-5.1.3 1088 release: "test" 1089 heritage: "Tiller" 1090 spec: 1091 type: ClusterIP 1092 ports: 1093 - name: redis 1094 port: 6379 1095 targetPort: redis 1096 selector: 1097 app: redis 1098 release: "test" 1099 role: master 1100 1101 --- 1102 # Source: redis/templates/redis-slave-svc.yaml 1103 1104 apiVersion: v1 1105 kind: Service 1106 metadata: 1107 name: test-redis-slave 1108 labels: 1109 app: redis 1110 chart: redis-5.1.3 1111 release: "test" 1112 heritage: "Tiller" 1113 spec: 1114 type: ClusterIP 1115 ports: 1116 - name: redis 1117 port: 6379 1118 targetPort: redis 1119 selector: 1120 app: redis 1121 release: "test" 1122 role: slave 1123 1124 --- 1125 # Source: redis/templates/redis-slave-deployment.yaml 1126 1127 apiVersion: extensions/v1beta1 1128 kind: Deployment 1129 metadata: 1130 name: test-redis-slave 1131 labels: 1132 app: redis 1133 chart: redis-5.1.3 1134 release: "test" 1135 heritage: "Tiller" 1136 spec: 1137 replicas: 1 1138 selector: 1139 matchLabels: 1140 release: "test" 1141 role: slave 1142 app: redis 1143 template: 1144 metadata: 1145 labels: 1146 release: "test" 1147 chart: redis-5.1.3 1148 role: slave 1149 app: redis 1150 annotations: 1151 checksum/health: 0fb018ad71cf7f2bf0bc3482d40b88ccbe3df15cb2a0d51a1f75d02398661bfe 1152 checksum/configmap: 3ba8fa67229e9f3c03390d9fb9d470d323c0f0f3e07d581e8f46f261945d241b 1153 checksum/secret: a1edae0cd29184bb1b5065b2388ec3d8c9ccd21eaac533ffceae4fe5ff7ac159 1154 spec: 1155 securityContext: 1156 fsGroup: 1001 1157 runAsUser: 1001 1158 serviceAccountName: "default" 1159 containers: 1160 - name: test-redis 1161 image: docker.io/bitnami/redis:4.0.12 1162 imagePullPolicy: "Always" 1163 command: 1164 - /run.sh 1165 1166 args: 1167 - "--port" 1168 - "$(REDIS_PORT)" 1169 - "--slaveof" 1170 - "$(REDIS_MASTER_HOST)" 1171 - "$(REDIS_MASTER_PORT_NUMBER)" 1172 - "--requirepass" 1173 - "$(REDIS_PASSWORD)" 1174 - "--masterauth" 1175 - "$(REDIS_MASTER_PASSWORD)" 1176 - "--include" 1177 - "/opt/bitnami/redis/etc/redis.conf" 1178 - "--include" 1179 - "/opt/bitnami/redis/etc/replica.conf" 1180 env: 1181 - name: REDIS_REPLICATION_MODE 1182 value: slave 1183 - name: REDIS_MASTER_HOST 1184 value: test-redis-master 1185 - name: REDIS_PORT 1186 value: "6379" 1187 - name: REDIS_MASTER_PORT_NUMBER 1188 value: "6379" 1189 - name: REDIS_PASSWORD 1190 valueFrom: 1191 secretKeyRef: 1192 name: test-redis 1193 key: redis-password 1194 - name: REDIS_MASTER_PASSWORD 1195 valueFrom: 1196 secretKeyRef: 1197 name: test-redis 1198 key: redis-password 1199 ports: 1200 - name: redis 1201 containerPort: 6379 1202 livenessProbe: 1203 initialDelaySeconds: 5 1204 periodSeconds: 5 1205 timeoutSeconds: 5 1206 successThreshold: 1 1207 failureThreshold: 5 1208 exec: 1209 command: 1210 - sh 1211 - -c 1212 - /health/ping_local_and_master.sh 1213 readinessProbe: 1214 initialDelaySeconds: 5 1215 periodSeconds: 5 1216 timeoutSeconds: 1 1217 successThreshold: 1 1218 failureThreshold: 5 1219 exec: 1220 command: 1221 - sh 1222 - -c 1223 - /health/ping_local_and_master.sh 1224 resources: 1225 null 1226 1227 volumeMounts: 1228 - name: health 1229 mountPath: /health 1230 - name: redis-data 1231 mountPath: /data 1232 - name: config 1233 mountPath: /opt/bitnami/redis/etc 1234 volumes: 1235 - name: health 1236 configMap: 1237 name: test-redis-health 1238 defaultMode: 0755 1239 - name: config 1240 configMap: 1241 name: test-redis 1242 - name: redis-data 1243 emptyDir: {} 1244 1245 --- 1246 # Source: redis/templates/redis-master-statefulset.yaml 1247 apiVersion: apps/v1beta2 1248 kind: StatefulSet 1249 metadata: 1250 name: test-redis-master 1251 labels: 1252 app: redis 1253 chart: redis-5.1.3 1254 release: "test" 1255 heritage: "Tiller" 1256 spec: 1257 selector: 1258 matchLabels: 1259 release: "test" 1260 role: master 1261 app: redis 1262 serviceName: test-redis-master 1263 template: 1264 metadata: 1265 labels: 1266 release: "test" 1267 chart: redis-5.1.3 1268 role: master 1269 app: redis 1270 annotations: 1271 checksum/health: 0fb018ad71cf7f2bf0bc3482d40b88ccbe3df15cb2a0d51a1f75d02398661bfe 1272 checksum/configmap: 3ba8fa67229e9f3c03390d9fb9d470d323c0f0f3e07d581e8f46f261945d241b 1273 checksum/secret: 4ce19ad3da007ff5f0c283389f765d43b33ed5fa4fcfb8e212308bedc33d62b2 1274 spec: 1275 securityContext: 1276 fsGroup: 1001 1277 runAsUser: 1001 1278 serviceAccountName: "default" 1279 containers: 1280 - name: test-redis 1281 image: "docker.io/bitnami/redis:4.0.12" 1282 imagePullPolicy: "Always" 1283 command: 1284 - /run.sh 1285 1286 args: 1287 - "--port" 1288 - "$(REDIS_PORT)" 1289 - "--requirepass" 1290 - "$(REDIS_PASSWORD)" 1291 - "--include" 1292 - "/opt/bitnami/redis/etc/redis.conf" 1293 - "--include" 1294 - "/opt/bitnami/redis/etc/master.conf" 1295 env: 1296 - name: REDIS_REPLICATION_MODE 1297 value: master 1298 - name: REDIS_PASSWORD 1299 valueFrom: 1300 secretKeyRef: 1301 name: test-redis 1302 key: redis-password 1303 - name: REDIS_PORT 1304 value: "6379" 1305 ports: 1306 - name: redis 1307 containerPort: 6379 1308 livenessProbe: 1309 initialDelaySeconds: 5 1310 periodSeconds: 5 1311 timeoutSeconds: 5 1312 successThreshold: 1 1313 failureThreshold: 5 1314 exec: 1315 command: 1316 - sh 1317 - -c 1318 - /health/ping_local.sh 1319 readinessProbe: 1320 initialDelaySeconds: 5 1321 periodSeconds: 5 1322 timeoutSeconds: 1 1323 successThreshold: 1 1324 failureThreshold: 5 1325 exec: 1326 command: 1327 - sh 1328 - -c 1329 - /health/ping_local.sh 1330 resources: 1331 null 1332 1333 volumeMounts: 1334 - name: health 1335 mountPath: /health 1336 - name: redis-data 1337 mountPath: /data 1338 subPath: 1339 - name: config 1340 mountPath: /opt/bitnami/redis/etc 1341 initContainers: 1342 - name: volume-permissions 1343 image: "docker.io/bitnami/minideb:latest" 1344 imagePullPolicy: "IfNotPresent" 1345 command: ["/bin/chown", "-R", "1001:1001", "/data"] 1346 securityContext: 1347 runAsUser: 0 1348 volumeMounts: 1349 - name: redis-data 1350 mountPath: /data 1351 subPath: 1352 volumes: 1353 - name: health 1354 configMap: 1355 name: test-redis-health 1356 defaultMode: 0755 1357 - name: config 1358 configMap: 1359 name: test-redis 1360 volumeClaimTemplates: 1361 - metadata: 1362 name: redis-data 1363 labels: 1364 app: "redis" 1365 component: "master" 1366 release: "test" 1367 heritage: "Tiller" 1368 spec: 1369 accessModes: 1370 - "ReadWriteOnce" 1371 resources: 1372 requests: 1373 storage: "8Gi" 1374 updateStrategy: 1375 type: RollingUpdate 1376 1377 --- 1378 # Source: redis/templates/metrics-deployment.yaml 1379 1380 1381 --- 1382 # Source: redis/templates/metrics-prometheus.yaml 1383 1384 --- 1385 # Source: redis/templates/metrics-svc.yaml 1386 1387 1388 --- 1389 # Source: redis/templates/networkpolicy.yaml 1390 1391 1392 --- 1393 # Source: redis/templates/redis-role.yaml 1394 1395 --- 1396 # Source: redis/templates/redis-rolebinding.yaml 1397 1398 --- 1399 # Source: redis/templates/redis-serviceaccount.yaml 1400 ` 1401 1402 // Example CRD YAML from: 1403 // https://github.com/martin-helmich/kubernetes-crd-example/tree/master/kubernetes 1404 const CRDYAML = ` 1405 apiVersion: apiextensions.k8s.io/v1beta1 1406 kind: CustomResourceDefinition 1407 metadata: 1408 name: projects.example.martin-helmich.de 1409 spec: 1410 group: example.martin-helmich.de 1411 names: 1412 kind: Project 1413 plural: projects 1414 singular: project 1415 scope: Namespaced 1416 validation: 1417 openAPIV3Schema: 1418 properties: 1419 spec: 1420 properties: 1421 image: docker.io/bitnami/minideb:latest 1422 replicas: 1423 minimum: 1 1424 type: integer 1425 required: 1426 - replicas 1427 required: 1428 - spec 1429 version: v1alpha1 1430 1431 --- 1432 apiVersion: example.martin-helmich.de/v1alpha1 1433 kind: Project 1434 metadata: 1435 name: example-project 1436 namespace: default 1437 spec: 1438 replicas: 1 1439 ` 1440 1441 const CRDImage = "docker.io/bitnami/minideb:latest" 1442 1443 const CRDImageObjectYAML = `apiVersion: tilt.dev/v1alpha1 1444 kind: UselessMachine 1445 metadata: 1446 name: um 1447 spec: 1448 imageObject: 1449 repo: frontend 1450 ` 1451 1452 const CRDContainerSpecYAML = `apiVersion: tilt.dev/v1alpha1 1453 kind: UselessMachine 1454 metadata: 1455 name: um 1456 spec: 1457 containers: 1458 - name: frontend 1459 image: frontend 1460 imagePullPolicy: "Always" 1461 ` 1462 1463 const MyNamespaceYAML = `apiVersion: v1 1464 kind: Namespace 1465 metadata: 1466 name: mynamespace 1467 ` 1468 const MyNamespaceName = "mynamespace" 1469 1470 const RedisStatefulSetYAML = ` 1471 # Modified from: redis/templates/redis-master-statefulset.yaml 1472 apiVersion: apps/v1beta2 1473 kind: StatefulSet 1474 metadata: 1475 name: test-redis-master 1476 labels: 1477 app: redis 1478 chart: redis-5.1.3 1479 release: "test" 1480 heritage: "Tiller" 1481 spec: 1482 selector: 1483 matchLabels: 1484 release: "test" 1485 role: master 1486 app: redis 1487 serviceName: test-redis-master 1488 template: 1489 metadata: 1490 labels: 1491 release: "test" 1492 chart: redis-5.1.3 1493 role: master 1494 app: redis 1495 spec: 1496 securityContext: 1497 fsGroup: 1001 1498 runAsUser: 1001 1499 serviceAccountName: "default" 1500 containers: 1501 - name: test-redis 1502 image: "docker.io/bitnami/redis:4.0.12" 1503 imagePullPolicy: "Always" 1504 command: 1505 - /run.sh 1506 1507 args: 1508 - "--port" 1509 - "$(REDIS_PORT)" 1510 - "--requirepass" 1511 - "$(REDIS_PASSWORD)" 1512 - "--include" 1513 - "/opt/bitnami/redis/etc/redis.conf" 1514 - "--include" 1515 - "/opt/bitnami/redis/etc/master.conf" 1516 env: 1517 - name: REDIS_REPLICATION_MODE 1518 value: master 1519 - name: REDIS_PASSWORD 1520 valueFrom: 1521 secretKeyRef: 1522 name: test-redis 1523 key: redis-password 1524 - name: REDIS_PORT 1525 value: "6379" 1526 ports: 1527 - name: redis 1528 containerPort: 6379 1529 volumeMounts: 1530 - name: health 1531 mountPath: /health 1532 - name: redis-data 1533 mountPath: /data 1534 subPath: 1535 - name: config 1536 mountPath: /opt/bitnami/redis/etc 1537 initContainers: 1538 - name: volume-permissions 1539 image: "docker.io/bitnami/minideb:latest" 1540 imagePullPolicy: "IfNotPresent" 1541 command: ["/bin/chown", "-R", "1001:1001", "/data"] 1542 securityContext: 1543 runAsUser: 0 1544 volumeMounts: 1545 - name: redis-data 1546 mountPath: /data 1547 subPath: 1548 volumes: 1549 - name: health 1550 configMap: 1551 name: test-redis-health 1552 defaultMode: 0755 1553 - name: config 1554 configMap: 1555 name: test-redis 1556 volumeClaimTemplates: 1557 - metadata: 1558 name: redis-data 1559 labels: 1560 app: "redis" 1561 component: "master" 1562 release: "test" 1563 heritage: "Tiller" 1564 spec: 1565 accessModes: 1566 - "ReadWriteOnce" 1567 resources: 1568 requests: 1569 storage: "8Gi" 1570 updateStrategy: 1571 type: RollingUpdate 1572 ` 1573 1574 func Deployment(name string, imageName string) string { 1575 result := ` 1576 apiVersion: apps/v1 1577 kind: Deployment 1578 metadata: 1579 name: NAME 1580 labels: 1581 app: NAME 1582 spec: 1583 replicas: 1 1584 selector: 1585 matchLabels: 1586 app: NAME 1587 template: 1588 metadata: 1589 labels: 1590 app: NAME 1591 spec: 1592 containers: 1593 - name: NAME 1594 image: IMAGE 1595 ` 1596 result = strings.ReplaceAll(result, "NAME", name) 1597 result = strings.ReplaceAll(result, "IMAGE", imageName) 1598 return result 1599 } 1600 1601 const PodDisruptionBudgetYAML = ` 1602 apiVersion: policy/v1beta1 1603 kind: PodDisruptionBudget 1604 metadata: 1605 labels: 1606 app: zookeeper 1607 name: infra-kafka-zookeeper 1608 spec: 1609 maxUnavailable: 1 1610 selector: 1611 matchLabels: 1612 app: zookeeper 1613 component: server 1614 release: infra-kafka 1615 ` 1616 1617 const DoggosListYAML = ` 1618 apiVersion: v1 1619 kind: List 1620 items: 1621 - apiVersion: v1 1622 kind: Service 1623 metadata: 1624 name: doggos 1625 labels: 1626 app: doggos 1627 whosAGoodBoy: imAGoodBoy 1628 spec: 1629 ports: 1630 - port: 80 1631 targetPort: 8083 1632 protocol: TCP 1633 selector: 1634 app: doggos 1635 - apiVersion: apps/v1 1636 kind: Deployment 1637 metadata: 1638 name: doggos 1639 labels: 1640 app: doggos 1641 breed: corgi 1642 whosAGoodBoy: imAGoodBoy 1643 namespace: the-dog-zone 1644 spec: 1645 selector: 1646 matchLabels: 1647 app: doggos 1648 breed: corgi 1649 whosAGoodBoy: imAGoodBoy 1650 template: 1651 metadata: 1652 labels: 1653 app: doggos 1654 breed: corgi 1655 whosAGoodBoy: imAGoodBoy 1656 tier: web 1657 spec: 1658 containers: 1659 - name: doggos 1660 image: gcr.io/windmill-public-containers/servantes/doggos 1661 command: ["/go/bin/doggos"] 1662 ` 1663 1664 const KnativeServingCore = ` 1665 --- 1666 # Copyright 2018 The Knative Authors 1667 # 1668 # Licensed under the Apache License, Version 2.0 (the "License"); 1669 # you may not use this file except in compliance with the License. 1670 # You may obtain a copy of the License at 1671 # 1672 # https://www.apache.org/licenses/LICENSE-2.0 1673 # 1674 # Unless required by applicable law or agreed to in writing, software 1675 # distributed under the License is distributed on an "AS IS" BASIS, 1676 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1677 # See the License for the specific language governing permissions and 1678 # limitations under the License. 1679 1680 apiVersion: caching.internal.knative.dev/v1alpha1 1681 kind: Image 1682 metadata: 1683 name: queue-proxy 1684 namespace: knative-serving 1685 labels: 1686 serving.knative.dev/release: "v0.15.0" 1687 spec: 1688 # This is the Go import path for the binary that is containerized 1689 # and substituted here. 1690 image: gcr.io/knative-releases/knative.dev/serving/cmd/queue@sha256:713bd548700bf7fe5452969611d1cc987051bd607d67a4e7623e140f06c209b2 1691 1692 `