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...2 min read
When performing rolling updates we can see it's history using kubectl rollout history:
$ kubectl rollout history deploy pet2cattle
deployment.apps/pet2cattle
REVISION CHANGE-CAUSE
100 <none>
101 <none>
102 <none>
103 <none>
104 <none>
105 <none>
106 <none>
107 <none>
109 kubectl scale deployment/pet2cattle --replicas=2 --record=true
110 kubectl scale deployment/pet2cattle --replicas=5 --record=true
111 kubectl scale deployment/pet2cattle --replicas=1 --record=true
If have any problem with the update we can undo and update using kubectl rollout undo
25/05/2021
Read more...2 min read
If you have an existing EBS volume that you want to use on your EKS cluster, or you don't want to let Kubernetes to manage your volumes, you can use awsElasticBlockStore to link an existing EBS volume to a PersistentVolume or use it directly as a volume on a pod spec:
24/05/2021
Read more...2 min read
Using openssl we can create a self-signed using a non interactive command suitable for automation if we give all the information at once such as the CN, and the days to expire
21/05/2021
Read more...1 min read
On the terraform 0.15 CHANGELOG we can see that they have added the one function. This function is intended to simplify existing code, improving it's readability and further smoothen the terraform learning curve
20/05/2021
Read more...1 min read
To be able to partially apply commits to other branches some times comes handy to use git reset together with git stash.
With git reset we will be able to modify how the changes are stored on the repository. Let's see the differences between git reset --soft and git reset --hard.
19/05/2021
Read more...3 min read
On Kubernetes, when we update objects such as a deployment or a daemonset we can check it's rollout history using kubectl rollout history:
$ kubectl rollout history deploy pet2cattle
deployment.apps/pet2cattle
REVISION CHANGE-CAUSE
21 <none>
22 <none>
23 <none>
24 <none>
26 <none>
28 <none>
29 <none>
30 <none>
32 <none>
33 <none>
34 <none>
By default we won't be able to see a change cause, but we can fill this gap by setting the command that triggered the update adding the --record flag as follows:
$ kubectl scale deployment/pet2cattle --replicas 2 --record
deployment.apps/pet2cattle scaled
18/05/2021
Read more...