github.com/KusionStack/kpm@v0.8.4-0.20240326033734-dc72298a30e5/test/e2e/test_suites/test_data/test_kpm_run_quiet/main.k (about)

     1  import catalog.models.schema.v1 as ac
     2  import catalog.models.schema.v1.trait as t
     3  import catalog.models.schema.v1.workload as wl
     4  import catalog.models.schema.v1.workload.container as c
     5  import catalog.models.schema.v1.workload.container.probe as p
     6  import catalog.models.schema.v1.workload.secret as sec
     7  import catalog.models.schema.v1.workload.network as n
     8  import catalog.models.schema.v1.monitoring as m
     9  
    10  # base.k declares reusable configurations for all stacks.
    11  helloworld: ac.AppConfiguration {
    12      workload: wl.Service {
    13          containers: {
    14              "nginx": c.Container {
    15                  image: "nginx:v1"
    16                  # Run the following command as defined
    17                  command: ["/bin/sh", "-c", "echo hi"]
    18                  # Extra arguments append to command defined above
    19                  args: ["/bin/sh", "-c", "echo hi"]
    20                  env: {
    21                      # An environment variable of name "env1" and value "VALUE" will be set
    22                      "env1": "VALUE"
    23                      # An environment variable of name "env2" and value of the key "key" in the
    24                      # secret named "sec-name" will be set.
    25                      "env2": "secret://sec-name/key"
    26                  }
    27                  # Run the command "/bin/sh -c echo hi", as defined above, in the directory "/tmp"
    28                  workingDir: "/tmp"
    29                  resources: {
    30                      "cpu": "2"
    31                      "memory": "4Gi"
    32                  }
    33                  # Configure a HTTP readiness probe
    34                  readinessProbe: p.Probe {
    35                      probeHandler: p.Http {
    36                          url: "http://localhost:80"
    37                      }
    38                      initialDelaySeconds: 10
    39                  }
    40              }
    41          }
    42          secrets: {
    43              "basic-auth": sec.Secret {
    44                  $type: "basic"
    45                  data: {
    46                      "username": "admin"
    47                      "password": "******"
    48                  }
    49              }
    50          }
    51          replicas: 2
    52          ports: [
    53              n.Port {
    54                  port: 80
    55                  targetPort: 8080
    56                  protocol: "TCP"
    57                  public: True
    58              }
    59          ]
    60      }
    61  }
    62  
    63  helloworldcollaset: ac.AppConfiguration {
    64      workload: wl.Service {
    65          containers: {
    66              "nginx": c.Container {
    67                  image: "nginx:v1"
    68                  # Run the following command as defined
    69                  command: ["/bin/sh", "-c", "echo hi"]
    70                  # Extra arguments append to command defined above
    71                  args: ["/bin/sh", "-c", "echo hi"]
    72                  # Run the command "/bin/sh -c echo hi", as defined above, in the directory "/tmp"
    73                  workingDir: "/tmp"
    74              }  
    75          }
    76          ports: [
    77              n.Port {
    78                  port: 80
    79              }
    80          ]
    81      }
    82      opsRule: t.OpsRule {
    83          maxUnavailable: "30%"
    84      }
    85  }
    86  
    87  helloworldjob: ac.AppConfiguration {
    88      workload: wl.Job {
    89          containers: {
    90              "busybox": c.Container {
    91                  image: "busybox:1.28"
    92                  # Run the following command as defined
    93                  command: ["/bin/sh", "-c", "echo hello"]
    94              }
    95          }
    96          # Run every hour.
    97          schedule: "0 * * * *"
    98      }
    99  }