Author SHA1 Message Date
darryl e0e74cf707 Update nginx/nginx2-deployment.yaml 2025-04-26 00:30:51 +02:00
darryl ea0c6338d2 test nginx 2025-04-26 00:19:32 +02:00
Darryl Ashburner 3038941fc1 added 2025-04-26 00:16:02 +02:00
darryl 0a8a574b61 Update guestbook/guestbook-ui-deployment.yaml 2025-04-25 23:38:17 +02:00
darryl 0cef800949 Update guestbook/guestbook-ui-deployment.yaml 2025-04-25 23:31:59 +02:00
darryl 1440eec578 Update guestbook/guestbook-ui-deployment.yaml 2025-04-25 23:28:00 +02:00
darryl 59c2717883 Update guestbook/guestbook-ui-deployment.yaml 2025-04-25 23:25:14 +02:00
darryl ce830c8496 Update guestbook/guestbook-ui-deployment.yaml 2025-04-25 23:19:44 +02:00
darryl b9149168c1 Update guestbook/guestbook-ui-deployment.yaml 2025-04-25 23:18:14 +02:00
Vladimir Pouzanov 4773b9f1f8 Add the nix setup guidelines (#244)
Signed-off-by: Vladimir Pouzanov <farcaller@gmail.com>
2025-01-17 17:22:00 -05:00
Thomas Güttler 25eeaf3e0a removed ksonnet (#169) 2025-01-17 17:19:29 -05:00
John Win ba44faf0a7 Updating plugins/kustomized-helm example (#156)
Updating the `helm template` command with a more complete example.
This command more resembles the helm command that is executed by the built-in helm tooling.

Signed-off-by: John Win <jpaulodit@hotmail.com>
2025-01-17 17:17:48 -05:00
Daniel Helfand ce918f91b3 chore: remove ksonnet example (#129)
Signed-off-by: Daniel Helfand <helfand.4@gmail.com>
2025-01-17 17:14:05 -05:00
gaborfinta 67763d1415 fix: Add carts service (#81)
* Add carts service

Signed-off-by: Finta Gabor <finta.gabor@alerant.hu>

* Add newline at end of file

Signed-off-by: Finta Gabor <finta.gabor@alerant.hu>

---------

Signed-off-by: Finta Gabor <finta.gabor@alerant.hu>
2025-01-17 17:13:34 -05:00
Anand Francis Joseph d7927a27b4 Template variable for container port (#251)
Signed-off-by: Anand Francis Joseph <anjoseph@redhat.com>
2023-11-15 09:00:20 -05:00
26 changed files with 247 additions and 193 deletions

No files matched your search

-1
View File
@@ -7,7 +7,6 @@ to explore ArgoCD and GitOps!
| Application | Description |
|-------------|-------------|
| [guestbook](guestbook/) | A hello word guestbook app as plain YAML |
| [ksonnet-guestbook](ksonnet-guestbook/) | The guestbook app as a ksonnet app |
| [helm-guestbook](helm-guestbook/) | The guestbook app as a Helm chart |
| [jsonnet-guestbook](jsonnet-guestbook/) | The guestbook app as a raw jsonnet |
| [jsonnet-guestbook-tla](jsonnet-guestbook-tla/) | The guestbook app as a raw jsonnet with support for top level arguments |
+1 -1
View File
@@ -26,7 +26,7 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
containerPort: {{ .Values.containerPort }}
protocol: TCP
livenessProbe:
httpGet:
+2
View File
@@ -9,6 +9,8 @@ image:
tag: 0.1
pullPolicy: IfNotPresent
containerPort: 80
service:
type: ClusterIP
port: 80
-4
View File
@@ -1,4 +0,0 @@
/lib
/.ksonnet/registries
/app.override.yaml
/.ks_environment
-23
View File
@@ -1,23 +0,0 @@
apiVersion: 0.1.0
environments:
default:
destination:
namespace: default
server: https://kubernetes.default.svc
k8sVersion: v1.10.0
path: default
dev:
destination:
namespace: dev
server: https://kubernetes.default.svc
k8sVersion: v1.10.0
path: dev
prod:
destination:
namespace: prod
server: https://kubernetes.default.svc
k8sVersion: v1.10.0
path: prod
kind: ksonnet.io/app
name: guestbook
version: 0.0.1
@@ -1,59 +0,0 @@
local env = std.extVar("__ksonnet/environments");
local params = std.extVar("__ksonnet/params").components["guestbook-ui"];
[
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"name": params.name
},
"spec": {
"ports": [
{
"port": params.servicePort,
"targetPort": params.containerPort
}
],
"selector": {
"app": params.name
},
"type": params.type
}
},
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": params.name
},
"spec": {
"replicas": params.replicas,
"revisionHistoryLimit": 3,
"selector": {
"matchLabels": {
"app": params.name
},
},
"template": {
"metadata": {
"labels": {
"app": params.name
}
},
"spec": {
"containers": [
{
"image": params.image,
"name": params.name,
"ports": [
{
"containerPort": params.containerPort
}
]
}
]
}
}
}
}
]
@@ -1,18 +0,0 @@
{
global: {
// User-defined global parameters; accessible to all component and environments, Ex:
// replicas: 4,
},
components: {
// Component-level parameters, defined initially from 'ks prototype use ...'
// Each object below should correspond to a component in the components/ directory
"guestbook-ui": {
containerPort: 80,
image: "gcr.io/heptio-images/ks-guestbook-demo:0.2",
name: "ks-guestbook-ui",
replicas: 1,
servicePort: 80,
type: "LoadBalancer",
},
},
}
@@ -1,4 +0,0 @@
local components = std.extVar("__ksonnet/components");
components + {
// Insert user-specified overrides here.
}
@@ -1,2 +0,0 @@
{
}
@@ -1,8 +0,0 @@
local base = import "base.libsonnet";
// uncomment if you reference ksonnet-lib
// local k = import "k.libsonnet";
base + {
// Insert user-specified overrides here. For example if a component is named \"nginx-deployment\", you might have something like:\n")
// "nginx-deployment"+: k.deployment.mixin.metadata.labels({foo: "bar"})
}
@@ -1,17 +0,0 @@
local params = std.extVar("__ksonnet/params");
local globals = import "globals.libsonnet";
local envParams = params + {
components +: {
// Insert component parameter overrides here. Ex:
// guestbook +: {
// name: "guestbook-dev",
// replicas: params.global.replicas,
// },
},
};
{
components: {
[x]: envParams.components[x] + globals, for x in std.objectFields(envParams.components)
},
}
@@ -1,2 +0,0 @@
{
}
@@ -1,8 +0,0 @@
local base = import "base.libsonnet";
// uncomment if you reference ksonnet-lib
// local k = import "k.libsonnet";
base + {
// Insert user-specified overrides here. For example if a component is named \"nginx-deployment\", you might have something like:\n")
// "nginx-deployment"+: k.deployment.mixin.metadata.labels({foo: "bar"})
}
@@ -1,17 +0,0 @@
local params = std.extVar("__ksonnet/params");
local globals = import "globals.libsonnet";
local envParams = params + {
components +: {
// Insert component parameter overrides here. Ex:
// guestbook +: {
// name: "guestbook-dev",
// replicas: params.global.replicas,
// },
},
};
{
components: {
[x]: envParams.components[x] + globals, for x in std.objectFields(envParams.components)
},
}
@@ -1,2 +0,0 @@
{
}
@@ -1,8 +0,0 @@
local base = import "base.libsonnet";
// uncomment if you reference ksonnet-lib
// local k = import "k.libsonnet";
base + {
// Insert user-specified overrides here. For example if a component is named \"nginx-deployment\", you might have something like:\n")
// "nginx-deployment"+: k.deployment.mixin.metadata.labels({foo: "bar"})
}
@@ -1,17 +0,0 @@
local params = std.extVar("__ksonnet/params");
local globals = import "globals.libsonnet";
local envParams = params + {
components +: {
// Insert component parameter overrides here. Ex:
// guestbook +: {
// name: "guestbook-dev",
// replicas: params.global.replicas,
// },
},
};
{
components: {
[x]: envParams.components[x] + globals, for x in std.objectFields(envParams.components)
},
}
+21
View File
@@ -0,0 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-2
labels:
app: nginx2
spec:
replicas: 1
selector:
matchLabels:
app: nginx2
template:
metadata:
labels:
app: nginx2
spec:
containers:
- name: nginx2
image: nginx:1.14.2
ports:
- containerPort: 80
+10
View File
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: nginx2
spec:
ports:
- port: 80
targetPort: 80
selector:
app: nginx2
+1
View File
@@ -4,3 +4,4 @@
|-------------|-------------|
| [kasane](kasane/) | The guestbook application as a `kasane` package. |
| [kustomized-helm](kustomized-helm/) | Application comprised of a `helm` chart and customized using `kustomize` |
| [nix](nix/) | Application comprised of a `helm` chart built and customized using `nix` |
+6 -2
View File
@@ -14,10 +14,14 @@ Use following steps to try the application:
command: ["/bin/sh", "-c"]
args: ["helm dependency build"]
generate:
command: [sh, -c]
args: ["helm template --release-name release-name . > all.yaml && kustomize build"]
command: ["/bin/sh", "-c"]
args: ["helm template . --name-template $ARGOCD_APP_NAME --namespace $ARGOCD_APP_NAMESPACE --kube-version $KUBE_VERSION > all.yaml && kustomize build"]
```
Notes:
- `$ARGOCD_APP_NAME`, `$ARGOCD_APP_NAMESPACE` and `$KUBE_VERSION` are environment variables that exists in the context of the plugin.
- setting `--kube-version` is important as helm template can mock up data which may not match the actual cluster version.
* create application using `kustomized-helm` as a config management plugin name:
+1
View File
@@ -0,0 +1 @@
result
+138
View File
@@ -0,0 +1,138 @@
# nix
[nix](https://nixos.org/) is a tool that takes a unique approach to package
management and system configuration.
This setup is based on the [NixCon 2023 talk](https://www.youtube.com/watch?v=SEA1Qm8K4gY).
## Set up the argo-cd installation for nix support
This setup uses the stock `nixos/nix:latest` image without any modifications.
That requires some changes in runtime, as nix cannot run as user 999 our of the
box.
Add the following bits to the values.yaml of your helm deployment:
```yaml
repoServer:
volumes:
- name: nix-cmp-config
configMap:
name: nix-cmp-config
- name: nix-cmp-tmp
emptyDir: {}
- name: nix-cmp-nix
emptyDir: {}
- name: nix-cmp-home
emptyDir: {}
initContainers:
- name: nix-bootstrap
# the init container copies the whole nix store and profiles into the
# temporary volume and makes sure the permissions are correct
command:
- "sh"
- "-c"
- "cp -a /nix/* /nixvol && chown -R 999 /nixvol/*"
image: nixos/nix:latest
# the image will always be updated at init step, so the one in the
# extraContainers must have the policy of Never to always be the same
# exact image.
imagePullPolicy: Always
volumeMounts:
- mountPath: /nixvol
name: nix-cmp-nix
extraContainers:
- name: nix-cmp-plugin
command:
- /var/run/argocd/argocd-cmp-server
image: nixos/nix:latest
imagePullPolicy: Never
securityContext:
runAsNonRoot: true
runAsUser: 999
volumeMounts:
- mountPath: /var/run/argocd
name: var-files
- mountPath: /home/argocd/cmp-server/plugins
name: plugins
- mountPath: /home/argocd/cmp-server/config/plugin.yaml
subPath: plugin.yaml
name: nix-cmp-config
- mountPath: /etc/passwd
subPath: passwd
name: nix-cmp-config
- mountPath: /etc/nix/nix.conf
subPath: nix.conf
name: nix-cmp-config
- mountPath: /tmp
name: nix-cmp-tmp
- mountPath: /nix
name: nix-cmp-nix
- mountPath: /home/nix
name: nix-cmp-home
```
## Add the plugin ConfigMap:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: nix-cmp-config
namespace: argocd
data:
nix.conf: |
build-users-group = nixbld
sandbox = false
experimental-features = nix-command flakes
substituters = https://cache.nixos.org https://nixhelm.cachix.org
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nixhelm.cachix.org-1:esqauAsR4opRF0UsGrA6H3gD21OrzMnBBYvJXeddjtY=
passwd: |
nix:x:999:30000:Nix build user 1:/home/nix:/bin/false
root:x:0:0::/root:/bin/bash
plugin.yaml: |
apiVersion: argoproj.io/v1alpha1
kind: ConfigManagementPlugin
metadata:
name: nix-cmp-plugin
spec:
discover:
fileName: flake.nix
generate:
command:
- sh
- "-c"
- cat result
init:
command:
- sh
- "-c"
- |
export OUTPUT="${ARGOCD_ENV_NIX_OUTPUT:-kubernetesConfiguration}"
echo -ne "Building for $OUTPUT\n" >/dev/stderr
if [ "$PARAM_VALUES" != "" ]; then
echo -ne "With values\n" >/dev/stderr
echo "$PARAM_VALUES" > values.json
nix-shell -p git --run ''git add values.json''
fi
if [ "$PARAM_IMPURE" == "true" ]; then
echo -ne "With impure\n" >/dev/stderr
IMPURE_FLAG="--impure"
else
IMPURE_FLAG=""
fi
nix build $IMPURE_FLAG ".#${OUTPUT}"
lockRepo: true
name: nix-cmp-plugin
version: v1.0
```
## Create a nix-based application
```
argocd app create simple-nginx \
--repo https://github.com/argoproj/argocd-example-apps \
--path plugins/nix \
--dest-server https://kubernetes.default.svc \
--dest-namespace default
```
+52
View File
@@ -0,0 +1,52 @@
{
inputs.nixhelm.url = "github:farcaller/nixhelm";
inputs.kubegen.url = "github:farcaller/nix-kube-generators";
outputs = { self, nixpkgs, nixhelm, kubegen, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
kubelib = kubegen.lib { inherit pkgs; };
addResources = yamlObjects: resources: builtins.foldl'
(acc: y: acc ++ [ y ])
resources
yamlObjects;
# You can define k8s objects using standard nix syntax
configMap = {
apiVersion = "v1";
kind = "ConfigMap";
metadata.name = "website";
data."index.html" = ''
<html>
<body>
<h1>Hello, nix world!</h1>
</body>
</html>
'';
};
in
{
packages.kubernetesConfiguration = pkgs.lib.pipe
{
name = "nginx";
# nixhelm provides a repository of various public helm charts converted to nix
chart = nixhelm.chartsDerivations.${system}.bitnami.nginx;
namespace = "default";
values = {
replicaCount = 2;
revisionHistoryLimit = 3;
staticSiteConfigmap = configMap.metadata.name;
};
} [
# lib.pipe is a handy function to run the processing over several functions in a sequence.
# The final output must gnerate a YAML file.
kubelib.buildHelmChart
builtins.readFile
kubelib.fromYAML
(addResources [configMap])
kubelib.mkList
kubelib.toYAMLFile
];
});
}
+14
View File
@@ -0,0 +1,14 @@
---
apiVersion: v1
kind: Service
metadata:
name: carts
labels:
name: carts
spec:
ports:
# the port that this service should serve on
- port: 80
targetPort: 80
selector:
name: carts
+1
View File
@@ -2,6 +2,7 @@ resources:
- base/carts-db-dep.yaml
- base/carts-db-svc.yaml
- base/carts-dep.yaml
- base/carts-svc.yaml
- base/catalogue-db-dep.yaml
- base/catalogue-db-svc.yaml
- base/catalogue-dep.yaml