2 min read
When defining objects that contain a pod template (such a Deployment or a Job) but also when defining a plain pod we can control under which circumstances a pod will be restarted
The container restart policy can be controlled using restartPolicy on the spec at the same level where we define the containers:
apiVersion: batch/v1
kind: Job
metadata:
name: demo-restartPolicy-job
spec:
backoffLimit: 2
template:
metadata:
name: demo-restartPolicy-pod
spec:
containers:
- name: demo
image: sonarsource/sonar-scanner-cli
restartPolicy: Never
01/06/2021
Read more...1 min read
If you need to known the amount of time it took a query to complete on PostgreSQL, you can use the \timing function that psql has
31/05/2021
Read more...2 min read
In the same way we can conditionally include a resource, we can also use for_each to conditionally include a nested block using terraform's dynamic blocks
For example, if we want to add a variable that controls whether we should set this value:
resource "helm_release" "spinnaker" {
name = "spinnaker"
(...)
set {
name = "halyard.additionalScripts.data.enable_mptv2"
type = "string"
value = <<-EOF
#!/bin/sh
cat $0
echo "custom mptv2"
$HAL_COMMAND config features edit --managed-pipeline-templates-v2-ui true
EOF
}
}
28/05/2021
Read more...3 min read
When we have a resource that can have multiple nested blocks to be configured we can use dynamic blocks to configure it dynamically. A perfect example is a SecurityGroup that can have multiple ingress and egress rules to be able to allow traffic. Let's use the following aws_security_group resource definition as a starting point:
resource "aws_security_group" "demo_sg" {
name = "demo_sg"
description = "pet2cattle demo SG with dynamic blocks"
vpc_id = aws_vpc.main.id
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = [aws_vpc.main.cidr_block]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
27/05/2021
Read more...3 min read
A kubernetes cluster can get outdated pretty soon since Kubernetes keeps evolving at every release. If we have a k3s cluster we can use the system-upgrade-controller for automatically handling the upgrades. Let's take a look on how to configure it
26/05/2021
Read more...