-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
483 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/* | ||
* Deploys the appuio-cloud-agent | ||
*/ | ||
local com = import 'lib/commodore.libjsonnet'; | ||
local kap = import 'lib/kapitan.libjsonnet'; | ||
local kube = import 'lib/kube.libjsonnet'; | ||
local inv = kap.inventory(); | ||
local params = inv.parameters.appuio_cloud; | ||
|
||
local image = params.images.agent; | ||
local loadManifest(manifest) = std.parseJson(kap.yaml_load('appuio-cloud/agent/manifests/' + image.tag + '/' + manifest)); | ||
|
||
local serviceAccount = loadManifest('rbac/service_account.yaml') { | ||
metadata+: { | ||
namespace: params.namespace, | ||
}, | ||
}; | ||
local role = com.namespaced(params.namespace, loadManifest('rbac/role.yaml')); | ||
local leaderElectionRole = com.namespaced(params.namespace, loadManifest('rbac/leader_election_role.yaml')); | ||
|
||
local webhookCertDir = '/var/run/webhook-service-tls'; | ||
|
||
local deployment = loadManifest('manager/manager.yaml') { | ||
metadata+: { | ||
namespace: params.namespace, | ||
}, | ||
spec+: { | ||
template+: { | ||
spec+: { | ||
replicas: params.agent.replicas, | ||
containers: [ | ||
if c.name == 'manager' then | ||
c { | ||
image: '%(registry)s/%(repository)s:%(tag)s' % image, | ||
args: [ | ||
'--leader-elect', | ||
'--webhook-cert-dir=' + webhookCertDir, | ||
'--memory-per-core-limit=' + params.agent['resource-ratio']['memory-per-core'], | ||
], | ||
volumeMounts+: [ | ||
{ | ||
name: 'webhook-service-tls', | ||
mountPath: webhookCertDir, | ||
readOnly: true, | ||
}, | ||
], | ||
} | ||
else | ||
c | ||
for c in super.containers | ||
], | ||
volumes+: [ | ||
{ | ||
name: 'webhook-service-tls', | ||
secret: { | ||
secretName: params.agent.webhook.tls.certSecretName, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
local admissionWebhookTlsSecret = | ||
assert std.length(params.agent.webhook.tls.certificate) > 0 : 'agent.webhook.tls.certificate is required'; | ||
assert std.length(params.agent.webhook.tls.key) > 0 : 'agent.webhook.tls.key is required'; | ||
kube.Secret(params.agent.webhook.tls.certSecretName) { | ||
metadata+: { | ||
namespace: params.namespace, | ||
}, | ||
type: 'kubernetes.io/tls', | ||
stringData: { | ||
'tls.key': params.agent.webhook.tls.key, | ||
'tls.crt': params.agent.webhook.tls.certificate, | ||
}, | ||
}; | ||
|
||
local admissionWebhook = loadManifest('webhook/manifests.yaml') { | ||
metadata+: { | ||
name: '%s-validating-webhook' % params.namespace, | ||
}, | ||
webhooks: [ | ||
w { | ||
clientConfig+: { | ||
[if std.length(params.agent.webhook.tls.caCertificate) > 0 then 'caBundle']: | ||
std.base64(params.agent.webhook.tls.caCertificate), | ||
service+: { | ||
namespace: params.namespace, | ||
}, | ||
}, | ||
namespaceSelector: params.agent.webhook.namespaceSelector, | ||
} | ||
for w in super.webhooks | ||
], | ||
}; | ||
|
||
local admissionWebhookService = loadManifest('webhook/service.yaml') { | ||
metadata+: { | ||
namespace: params.namespace, | ||
}, | ||
}; | ||
|
||
{ | ||
'01_role': role, | ||
'01_leader_election_role': leaderElectionRole, | ||
'01_role_binding': kube.ClusterRoleBinding(role.metadata.name) { | ||
roleRef: { | ||
kind: 'ClusterRole', | ||
apiGroup: 'rbac.authorization.k8s.io', | ||
name: role.metadata.name, | ||
}, | ||
subjects: [ | ||
{ | ||
kind: 'ServiceAccount', | ||
name: serviceAccount.metadata.name, | ||
namespace: serviceAccount.metadata.namespace, | ||
}, | ||
], | ||
}, | ||
'01_leader_election_role_binding': kube.RoleBinding(role.metadata.name) { | ||
metadata+: { | ||
namespace: params.namespace, | ||
}, | ||
roleRef: { | ||
kind: 'Role', | ||
apiGroup: 'rbac.authorization.k8s.io', | ||
name: leaderElectionRole.metadata.name, | ||
}, | ||
subjects: [ | ||
{ | ||
kind: 'ServiceAccount', | ||
name: serviceAccount.metadata.name, | ||
namespace: serviceAccount.metadata.namespace, | ||
}, | ||
], | ||
}, | ||
'01_service_account': serviceAccount, | ||
'02_webhook_cert_secret': admissionWebhookTlsSecret, | ||
'02_deployment': deployment, | ||
'10_webhook_config': admissionWebhook, | ||
'11_webhook_service': admissionWebhookService, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
tests/golden/defaults/appuio-cloud/appuio-cloud/01_agent/01_leader_election_role.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: appuio-cloud-agent:leader-election-role | ||
namespace: appuio-cloud | ||
rules: | ||
- apiGroups: | ||
- '' | ||
resources: | ||
- configmaps | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- create | ||
- update | ||
- patch | ||
- delete | ||
- apiGroups: | ||
- coordination.k8s.io | ||
resources: | ||
- leases | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- create | ||
- update | ||
- patch | ||
- delete | ||
- apiGroups: | ||
- '' | ||
resources: | ||
- events | ||
verbs: | ||
- create | ||
- patch |
16 changes: 16 additions & 0 deletions
16
...s/golden/defaults/appuio-cloud/appuio-cloud/01_agent/01_leader_election_role_binding.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
annotations: {} | ||
labels: | ||
name: appuio-cloud-agent | ||
name: appuio-cloud-agent | ||
namespace: appuio-cloud | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: appuio-cloud-agent:leader-election-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: appuio-cloud-agent | ||
namespace: appuio-cloud |
15 changes: 15 additions & 0 deletions
15
tests/golden/defaults/appuio-cloud/appuio-cloud/01_agent/01_role.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
creationTimestamp: null | ||
name: appuio-cloud-agent | ||
namespace: appuio-cloud | ||
rules: | ||
- apiGroups: | ||
- '' | ||
resources: | ||
- pods | ||
verbs: | ||
- get | ||
- list | ||
- watch |
15 changes: 15 additions & 0 deletions
15
tests/golden/defaults/appuio-cloud/appuio-cloud/01_agent/01_role_binding.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
annotations: {} | ||
labels: | ||
name: appuio-cloud-agent | ||
name: appuio-cloud-agent | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: appuio-cloud-agent | ||
subjects: | ||
- kind: ServiceAccount | ||
name: appuio-cloud-agent | ||
namespace: appuio-cloud |
5 changes: 5 additions & 0 deletions
5
tests/golden/defaults/appuio-cloud/appuio-cloud/01_agent/01_service_account.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: appuio-cloud-agent | ||
namespace: appuio-cloud |
62 changes: 62 additions & 0 deletions
62
tests/golden/defaults/appuio-cloud/appuio-cloud/01_agent/02_deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
control-plane: appuio-cloud-agent | ||
name: appuio-cloud-agent | ||
namespace: appuio-cloud | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
control-plane: appuio-cloud-agent | ||
template: | ||
metadata: | ||
annotations: | ||
kubectl.kubernetes.io/default-container: agent | ||
labels: | ||
control-plane: appuio-cloud-agent | ||
spec: | ||
containers: | ||
- args: | ||
- --leader-elect | ||
- --webhook-cert-dir=/var/run/webhook-service-tls | ||
- --memory-per-core-limit=4Gi | ||
command: | ||
- /appuio-cloud-agent | ||
image: ghcr.io/appuio/appuio-cloud-agent:v0.1.0 | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 8081 | ||
initialDelaySeconds: 15 | ||
periodSeconds: 20 | ||
name: manager | ||
ports: | ||
- containerPort: 9443 | ||
readinessProbe: | ||
httpGet: | ||
path: /readyz | ||
port: 8081 | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
resources: | ||
limits: | ||
cpu: 500m | ||
memory: 256Mi | ||
requests: | ||
cpu: 10m | ||
memory: 128Mi | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
volumeMounts: | ||
- mountPath: /var/run/webhook-service-tls | ||
name: webhook-service-tls | ||
readOnly: true | ||
replicas: 3 | ||
serviceAccountName: appuio-cloud-agent | ||
terminationGracePeriodSeconds: 10 | ||
volumes: | ||
- name: webhook-service-tls | ||
secret: | ||
secretName: webhook-service-tls |
Oops, something went wrong.