Solution

1 minute read
  1. The specification to define the seed CronJob is as follows:

    apiVersion: batch/v1
    kind: CronJob
    metadata:
      name: seed
    spec:
      schedule: "* * * * *"
      jobTemplate:
        metadata:
          name: seed
        spec:
          template:
            spec:
              containers:
              - image: voting/tools:latest
                name: seed
                env:
                - name: NUMBER_OF_VOTES
                  value: "10"
                imagePullPolicy: Always
              restartPolicy: OnFailure
    
  2. Deploy the application with the following command from the manifests directory:

kubectl apply -f .

Using the IP address of one of the cluster nodes, you can access the vote and result interfaces via ports 31000 and 31001 respectively. If you observe the result interface for a few minutes, you will see that 10 new votes are created every minute.

Results

  1. Delete the application with the following command from the manifests directory:
kubectl delete -f .