Argo CD and helm is not designed for S2I , but it can leverage S2i with certain setting - unix1998/technical_notes GitHub Wiki
Helm and Argo CD are primarily designed to work with container images and Kubernetes manifests. Using Source-to-Image (S2I) with these tools requires additional configurations compared to the typical Docker image workflow. Here’s how you can work with S2I using Helm and Argo CD:
Using S2I with Helm
Helm itself doesn't natively support S2I, but you can create Helm charts that include the necessary configurations to build and deploy applications using S2I. This involves defining the BuildConfig
and related resources within the Helm chart.
Example Helm Chart with S2I
Here’s an example of how you might structure a Helm chart to include S2I configurations:
- Chart Structure:
myapp/
Chart.yaml
values.yaml
templates/
buildconfig.yaml
imagestream.yaml
deployment.yaml
service.yaml
route.yaml
- templates/buildconfig.yaml:
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
name: {{ .Release.Name }}-build
spec:
source:
type: Git
git:
uri: {{ .Values.sourceRepo }}
strategy:
type: Source
sourceStrategy:
from:
kind: ImageStreamTag
name: 'nodejs:latest' # Replace with the appropriate builder image
output:
to:
kind: ImageStreamTag
name: '{{ .Release.Name }}:latest'
- templates/imagestream.yaml:
apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: {{ .Release.Name }}
- templates/deployment.yaml:
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
name: {{ .Release.Name }}
spec:
replicas: 1
selector:
app: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ .Release.Name }}
spec:
containers:
- name: {{ .Release.Name }}
image: '{{ .Release.Name }}:latest'
ports:
- containerPort: 8080
- templates/service.yaml:
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}
spec:
selector:
app: {{ .Release.Name }}
ports:
- port: 8080
targetPort: 8080
- templates/route.yaml:
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: {{ .Release.Name }}
spec:
to:
kind: Service
name: {{ .Release.Name }}
port:
targetPort: 8080
- values.yaml:
sourceRepo: https://github.com/username/repository.git
Deploying with Helm
You can deploy the Helm chart using:
helm install myapp ./myapp
Using S2I with Argo CD
Argo CD works with Kubernetes manifests and Helm charts, and can manage resources that define S2I builds. Here's how you might configure Argo CD to deploy an application that uses S2I:
-
Ensure your Kubernetes manifests or Helm charts include S2I configurations (similar to the example above).
-
Create an Argo CD Application Resource that points to your Helm chart or Kubernetes manifests.
Example Argo CD Application Resource
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp
spec:
project: default
source:
repoURL: 'https://github.com/username/repository.git'
path: 'charts/myapp'
targetRevision: HEAD
destination:
server: 'https://kubernetes.default.svc'
namespace: 'myapp-namespace'
syncPolicy:
automated:
prune: true
selfHeal: true
Deploying with Argo CD
- Add the Argo CD Application Resource to your Git repository.
- Apply the Application Resource to Argo CD:
kubectl apply -f argo-application.yaml
Argo CD will then monitor the repository for changes and apply them to the cluster.
Summary
- Helm and Argo CD do not natively support S2I: You need to include the necessary S2I configurations (e.g.,
BuildConfig
,ImageStream
) in your Helm charts or Kubernetes manifests. - Additional Configuration: Using S2I with Helm and Argo CD involves more setup compared to the typical Docker image workflow. You need to define the build configurations, image streams, and deployment configurations explicitly.
- Declarative Management: Despite the extra setup, you can manage S2I builds declaratively using Helm charts and Argo CD, maintaining a GitOps approach to application deployment.
This approach allows you to leverage the benefits of S2I for building images directly from source code while using Helm and Argo CD for deployment and continuous delivery.