mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
Add example application
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
apiVersion: 0.1.0
|
||||
gitVersion:
|
||||
commitSha: 422d521c05aa905df949868143b26445f5e4eda5
|
||||
refSpec: master
|
||||
kind: ksonnet.io/registry
|
||||
libraries:
|
||||
apache:
|
||||
path: apache
|
||||
version: master
|
||||
efk:
|
||||
path: efk
|
||||
version: master
|
||||
mariadb:
|
||||
path: mariadb
|
||||
version: master
|
||||
memcached:
|
||||
path: memcached
|
||||
version: master
|
||||
mongodb:
|
||||
path: mongodb
|
||||
version: master
|
||||
mysql:
|
||||
path: mysql
|
||||
version: master
|
||||
nginx:
|
||||
path: nginx
|
||||
version: master
|
||||
node:
|
||||
path: node
|
||||
version: master
|
||||
postgres:
|
||||
path: postgres
|
||||
version: master
|
||||
redis:
|
||||
path: redis
|
||||
version: master
|
||||
tomcat:
|
||||
path: tomcat
|
||||
version: master
|
||||
69
examples/guestbook/README.md
Normal file
69
examples/guestbook/README.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# Argo CD Getting Started
|
||||
|
||||
Guestbook app demonstrates how ArgoCD works, you can run examples of simple workflows and workflows that use artifacts.
|
||||
|
||||
## Requirements
|
||||
* Installed [minikube](https://github.com/kubernetes/minikube#installation)
|
||||
* Installed the [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) command-line tool
|
||||
* Have a [kubeconfig](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) file (default location is `~/.kube/config`).
|
||||
|
||||
## 1. Download Argo CD
|
||||
|
||||
`TO BE ADDED`
|
||||
|
||||
## 2. Install the Argo CD components
|
||||
```
|
||||
$ argocd install
|
||||
```
|
||||
|
||||
## 3. Open access to Argo CD API server and configure Argo CD CLI
|
||||
|
||||
By default Argo CD API server is not exposed with an external IP. To expose API server, change service type to `LoadBalancer` use the following command:
|
||||
|
||||
```
|
||||
$ kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
|
||||
```
|
||||
|
||||
Export API server URL into `ARGOCD_SERVER` environment variable using the following command":
|
||||
|
||||
```
|
||||
$ export ARGOCD_SERVER=$(minikube service argocd-server -n argocd --url | cut -d'/' -f 3)
|
||||
```
|
||||
|
||||
Now you Argo CD is able to talk to API server and you can deploy first application.
|
||||
|
||||
## 4. Connect and deploy Guestbook application
|
||||
|
||||
1. Register minicube cluster and github repository which contains Guestbook application:
|
||||
|
||||
```
|
||||
$ argocd repo add https://github.com/argoproj/argo-cd.git
|
||||
$ argocd cluster add minikube
|
||||
```
|
||||
|
||||
2. Add Guestbook application:
|
||||
|
||||
```
|
||||
$ argocd app add guestbook --repo https://github.com/argoproj/argo-cd.git --path examples/guestbook --env minikube
|
||||
```
|
||||
|
||||
Once application is added you can see application status using following commands:
|
||||
|
||||
```
|
||||
$ argocd app list
|
||||
$ argocd app sync guestbook
|
||||
```
|
||||
|
||||
The application status is `OutOfSync` and not Kubernetes resouces have been created since application is not deployed yet. To deploy application use following command:
|
||||
|
||||
```
|
||||
$ argocd app sync guestbook
|
||||
```
|
||||
|
||||
Argo CD allows to view and manager applications using web UI. Get the web UI URL using following command:
|
||||
|
||||
```
|
||||
minikube service argocd-server -n argocd --url
|
||||
```
|
||||
|
||||

|
||||
18
examples/guestbook/app.yaml
Normal file
18
examples/guestbook/app.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
apiVersion: 0.1.0
|
||||
environments:
|
||||
minikube:
|
||||
destination:
|
||||
namespace: default
|
||||
server: https://192.168.99.100:8443
|
||||
k8sVersion: v1.7.0
|
||||
path: minikube
|
||||
kind: ksonnet.io/app
|
||||
name: test-app
|
||||
registries:
|
||||
incubator:
|
||||
gitVersion:
|
||||
commitSha: 422d521c05aa905df949868143b26445f5e4eda5
|
||||
refSpec: master
|
||||
protocol: github
|
||||
uri: github.com/ksonnet/parts/tree/master/incubator
|
||||
version: 0.0.1
|
||||
BIN
examples/guestbook/argocd-ui.png
Normal file
BIN
examples/guestbook/argocd-ui.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 109 KiB |
29
examples/guestbook/components/guestbook-ui.jsonnet
Normal file
29
examples/guestbook/components/guestbook-ui.jsonnet
Normal file
@@ -0,0 +1,29 @@
|
||||
local env = std.extVar("__ksonnet/environments");
|
||||
local params = std.extVar("__ksonnet/params").components["guestbook-ui"];
|
||||
local k = import "k.libsonnet";
|
||||
local deployment = k.apps.v1beta1.deployment;
|
||||
local container = k.apps.v1beta1.deployment.mixin.spec.template.spec.containersType;
|
||||
local containerPort = container.portsType;
|
||||
local service = k.core.v1.service;
|
||||
local servicePort = k.core.v1.service.mixin.spec.portsType;
|
||||
|
||||
local targetPort = params.containerPort;
|
||||
local labels = {app: params.name};
|
||||
|
||||
local appService = service
|
||||
.new(
|
||||
params.name,
|
||||
labels,
|
||||
servicePort.new(params.servicePort, targetPort))
|
||||
.withType(params.type);
|
||||
|
||||
local appDeployment = deployment
|
||||
.new(
|
||||
params.name,
|
||||
params.replicas,
|
||||
container
|
||||
.new(params.name, params.image)
|
||||
.withPorts(containerPort.new(targetPort)),
|
||||
labels);
|
||||
|
||||
k.core.v1.list.new([appService, appDeployment])
|
||||
18
examples/guestbook/components/params.libsonnet
Normal file
18
examples/guestbook/components/params.libsonnet
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
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: "guestbook-ui",
|
||||
replicas: 1,
|
||||
servicePort: 80,
|
||||
type: "LoadBalancer",
|
||||
},
|
||||
},
|
||||
}
|
||||
4
examples/guestbook/environments/base.libsonnet
Normal file
4
examples/guestbook/environments/base.libsonnet
Normal file
@@ -0,0 +1,4 @@
|
||||
local components = std.extVar("__ksonnet/components");
|
||||
components + {
|
||||
// Insert user-specified overrides here.
|
||||
}
|
||||
7
examples/guestbook/environments/minikube/main.jsonnet
Normal file
7
examples/guestbook/environments/minikube/main.jsonnet
Normal file
@@ -0,0 +1,7 @@
|
||||
local base = import "base.libsonnet";
|
||||
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:
|
||||
// "nginx-deployment"+: k.deployment.mixin.metadata.labels({foo: "bar"})
|
||||
}
|
||||
10
examples/guestbook/environments/minikube/params.libsonnet
Normal file
10
examples/guestbook/environments/minikube/params.libsonnet
Normal file
@@ -0,0 +1,10 @@
|
||||
local params = import "../../components/params.libsonnet";
|
||||
params + {
|
||||
components +: {
|
||||
// Insert component parameter overrides here. Ex:
|
||||
// guestbook +: {
|
||||
// name: "guestbook-dev",
|
||||
// replicas: params.global.replicas,
|
||||
// },
|
||||
},
|
||||
}
|
||||
80
examples/guestbook/lib/v1.7.0/k.libsonnet
Normal file
80
examples/guestbook/lib/v1.7.0/k.libsonnet
Normal file
@@ -0,0 +1,80 @@
|
||||
local k8s = import "k8s.libsonnet";
|
||||
|
||||
local apps = k8s.apps;
|
||||
local core = k8s.core;
|
||||
local extensions = k8s.extensions;
|
||||
|
||||
local hidden = {
|
||||
mapContainers(f):: {
|
||||
local podContainers = super.spec.template.spec.containers,
|
||||
spec+: {
|
||||
template+: {
|
||||
spec+: {
|
||||
// IMPORTANT: This overwrites the 'containers' field
|
||||
// for this deployment.
|
||||
containers: std.map(f, podContainers),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
mapContainersWithName(names, f) ::
|
||||
local nameSet =
|
||||
if std.type(names) == "array"
|
||||
then std.set(names)
|
||||
else std.set([names]);
|
||||
local inNameSet(name) = std.length(std.setInter(nameSet, std.set([name]))) > 0;
|
||||
self.mapContainers(
|
||||
function(c)
|
||||
if std.objectHas(c, "name") && inNameSet(c.name)
|
||||
then f(c)
|
||||
else c
|
||||
),
|
||||
};
|
||||
|
||||
k8s + {
|
||||
apps:: apps + {
|
||||
v1beta1:: apps.v1beta1 + {
|
||||
local v1beta1 = apps.v1beta1,
|
||||
|
||||
daemonSet:: v1beta1.daemonSet + {
|
||||
mapContainers(f):: hidden.mapContainers(f),
|
||||
mapContainersWithName(names, f):: hidden.mapContainersWithName(names, f),
|
||||
},
|
||||
|
||||
deployment:: v1beta1.deployment + {
|
||||
mapContainers(f):: hidden.mapContainers(f),
|
||||
mapContainersWithName(names, f):: hidden.mapContainersWithName(names, f),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
core:: core + {
|
||||
v1:: core.v1 + {
|
||||
list:: {
|
||||
new(items)::
|
||||
{apiVersion: "v1"} +
|
||||
{kind: "List"} +
|
||||
self.items(items),
|
||||
|
||||
items(items):: if std.type(items) == "array" then {items+: items} else {items+: [items]},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
extensions:: extensions + {
|
||||
v1beta1:: extensions.v1beta1 + {
|
||||
local v1beta1 = extensions.v1beta1,
|
||||
|
||||
daemonSet:: v1beta1.daemonSet + {
|
||||
mapContainers(f):: hidden.mapContainers(f),
|
||||
mapContainersWithName(names, f):: hidden.mapContainersWithName(names, f),
|
||||
},
|
||||
|
||||
deployment:: v1beta1.deployment + {
|
||||
mapContainers(f):: hidden.mapContainers(f),
|
||||
mapContainersWithName(names, f):: hidden.mapContainersWithName(names, f),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
19351
examples/guestbook/lib/v1.7.0/k8s.libsonnet
Normal file
19351
examples/guestbook/lib/v1.7.0/k8s.libsonnet
Normal file
File diff suppressed because it is too large
Load Diff
56122
examples/guestbook/lib/v1.7.0/swagger.json
Normal file
56122
examples/guestbook/lib/v1.7.0/swagger.json
Normal file
File diff suppressed because it is too large
Load Diff
80
examples/guestbook/lib/v1.8.0/k.libsonnet
Normal file
80
examples/guestbook/lib/v1.8.0/k.libsonnet
Normal file
@@ -0,0 +1,80 @@
|
||||
local k8s = import "k8s.libsonnet";
|
||||
|
||||
local apps = k8s.apps;
|
||||
local core = k8s.core;
|
||||
local extensions = k8s.extensions;
|
||||
|
||||
local hidden = {
|
||||
mapContainers(f):: {
|
||||
local podContainers = super.spec.template.spec.containers,
|
||||
spec+: {
|
||||
template+: {
|
||||
spec+: {
|
||||
// IMPORTANT: This overwrites the 'containers' field
|
||||
// for this deployment.
|
||||
containers: std.map(f, podContainers),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
mapContainersWithName(names, f) ::
|
||||
local nameSet =
|
||||
if std.type(names) == "array"
|
||||
then std.set(names)
|
||||
else std.set([names]);
|
||||
local inNameSet(name) = std.length(std.setInter(nameSet, std.set([name]))) > 0;
|
||||
self.mapContainers(
|
||||
function(c)
|
||||
if std.objectHas(c, "name") && inNameSet(c.name)
|
||||
then f(c)
|
||||
else c
|
||||
),
|
||||
};
|
||||
|
||||
k8s + {
|
||||
apps:: apps + {
|
||||
v1beta1:: apps.v1beta1 + {
|
||||
local v1beta1 = apps.v1beta1,
|
||||
|
||||
daemonSet:: v1beta1.daemonSet + {
|
||||
mapContainers(f):: hidden.mapContainers(f),
|
||||
mapContainersWithName(names, f):: hidden.mapContainersWithName(names, f),
|
||||
},
|
||||
|
||||
deployment:: v1beta1.deployment + {
|
||||
mapContainers(f):: hidden.mapContainers(f),
|
||||
mapContainersWithName(names, f):: hidden.mapContainersWithName(names, f),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
core:: core + {
|
||||
v1:: core.v1 + {
|
||||
list:: {
|
||||
new(items)::
|
||||
{apiVersion: "v1"} +
|
||||
{kind: "List"} +
|
||||
self.items(items),
|
||||
|
||||
items(items):: if std.type(items) == "array" then {items+: items} else {items+: [items]},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
extensions:: extensions + {
|
||||
v1beta1:: extensions.v1beta1 + {
|
||||
local v1beta1 = extensions.v1beta1,
|
||||
|
||||
daemonSet:: v1beta1.daemonSet + {
|
||||
mapContainers(f):: hidden.mapContainers(f),
|
||||
mapContainersWithName(names, f):: hidden.mapContainersWithName(names, f),
|
||||
},
|
||||
|
||||
deployment:: v1beta1.deployment + {
|
||||
mapContainers(f):: hidden.mapContainers(f),
|
||||
mapContainersWithName(names, f):: hidden.mapContainersWithName(names, f),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
25121
examples/guestbook/lib/v1.8.0/k8s.libsonnet
Normal file
25121
examples/guestbook/lib/v1.8.0/k8s.libsonnet
Normal file
File diff suppressed because it is too large
Load Diff
73741
examples/guestbook/lib/v1.8.0/swagger.json
Normal file
73741
examples/guestbook/lib/v1.8.0/swagger.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user