Besides checking the source code quality, we should also verify if the commit into Git was done by someone/something we trust. It is a good practice to sign all commits to Git. You need to prepare your Git account and create trusted certificates.
I will not describe how exactly you need to configure Git to sign your commit. Verify the following link to learn more about Signing Commits
Goals
The goals of this step are:
Verify if the last commit has been signed
Prerequisites
Signing public key
Configured Git to verify your gpg signature
When your commit is signed, Git will show that:
Figure 1. Pipeline
Steps
Create the following Secret that contains your PUBLIC key.
kind: Secret
apiVersion: v1
metadata:
name: gpg-public-key
namespace: ci
data:
public.key: >-
<Base64 PUBLIC GPG KEY> (1)
type: Opaque
1
Public key, containing BEGIN/END lines base64 encoded.
Create the following Task:
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: verify-source-code-commit-signature
namespace: ci
spec:
description: This task verifies the latest commit and signature against the gpg
public key
params:
- default: 'registry.redhat.io/openshift-pipelines/pipelines-git-init-rhel8:v1.10.4-4'
name: gitInit
type: string
steps:
- computeResources: {}
image: $(params.gitInit)
name: git-verify
script: |
set -x (1)
gpg --import /workspace/secrets/public.key
git config --global --add safe.directory /workspace/repository
git verify-commit HEAD || (echo "Unable to verify commit at HEAD!" && exit 1)
workingDir: /workspace/repository
workspaces:
- name: repository
- name: secrets (2)
1
The script to verify the signature of the commit,
2
The workspace that mounts the Secret containing the gpg key,
Modify the TriggerTemplate and add the following 3 lines
Let’s update the README.md of our source code again to trigger another PipelineRun.
Now the 3rd task will verify if the commit was signed.
Figure 3. PipelineRun Details
In the logs of the Task, we can see that the commit was signed and could be verified.
See:
...
gpg: Good signature from "Thomas Jungbauer <tjungbau@redhat.com>"
...
Figure 4. Signature Verification
Summary
At this stage we have a Pipeline, that pulls our code, does a code analysis, and verifies if the commit has been signed.
The very next step is to build the image and push it into an Image Registry.
During my day-to-day business, I am discussing the following setup with many customers: Configure App-of-Apps. Here I try to explain how I use an ApplicationSet that watches over a folder in Git and automatically adds a new Argo CD Application whenever a new folder is found. This works great, but there is a catch: The ApplicationSet uses the same Namespace default for all Applications. This is not always desired, especially when you have different teams working on different Applications.
Recently I was asked by the customer if this can be fixed and if it is possible to define different Namespaces for each Application. The answer is yes, and I would like to show you how to do this.
Classic Kubernetes/OpenShift offer a feature called NetworkPolicy that allows users to control the traffic to and from their assigned Namespace. NetworkPolicies are designed to give project owners or tenants the ability to protect their own namespace. Sometimes, however, I worked with customers where the cluster administrators or a dedicated (network) team need to enforce these policies.
Since the NetworkPolicy API is namespace-scoped, it is not possible to enforce policies across namespaces. The only solution was to create custom (project) admin and edit roles, and remove the ability of creating, modifying or deleting NetworkPolicy objects. Technically, this is possible and easily done. But shifts the whole network security to cluster administrators.
Luckily, this is where AdminNetworkPolicy (ANP) and BaselineAdminNetworkPolicy (BANP) comes into play.
Lately I came across several issues where a given Helm Chart must be modified after it has been rendered by Argo CD. Argo CD does a helm template to render a Chart. Sometimes, especially when you work with Subcharts or when a specific setting is not yet supported by the Chart, you need to modify it later … you need to post-render the Chart.
In this very short article, I would like to demonstrate this on a real-live example I had to do. I would like to inject annotations to a Route objects, so that the certificate can be injected. This is done by the cert-utils operator. For the post-rendering the Argo CD repo pod will be extended with a sidecar container, that is watching for the repos and patches them if required.
The article SSL Certificate Management for OpenShift on AWS explains how to use the Cert-Manager Operator to request and install a new SSL Certificate. This time, I would like to leverage the GitOps approach using the Helm Chart cert-manager I have prepared to deploy the Operator and order new Certificates.
I will use an ACME Letsencrypt issuer with a DNS challenge. My domain is hosted at AWS Route 53.
However, any other integration can be easily used.
During a GitOps journey at one point, the question arises, how to update a cluster? Nowadays it is very easy to update a cluster using CLI or WebUI, so why bother with GitOps in that case? The reason is simple: Using GitOps you can be sure that all clusters are updated to the correct, required version and the version of each cluster is also managed in Git.
All you need is the channel you want to use and the desired cluster version. Optionally, you can define the exact image SHA. This might be required when you are operating in a restricted environment.