This repository has been archived by the owner on Oct 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding scaffolding for the tkg-autoscaler package
- Loading branch information
1 parent
05af520
commit 782557c
Showing
10 changed files
with
318 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Copyright 2022 VMware, Inc. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
configure-package: ## Configure package before creating the package | ||
|
||
reset-package: ## Reset configured package |
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,25 @@ | ||
# tkg-clusterclass-aws Package | ||
|
||
This package provides << awesome functionality >> using [tkg-autoscaler](https://INFO_NEEDED). | ||
|
||
## Components | ||
|
||
## Configuration | ||
|
||
The following configuration values can be set to customize the tkg-autoscaler installation. | ||
|
||
### Global | ||
|
||
| Value | Required/Optional | Description | | ||
|-------|-------------------|-------------| | ||
| `name` | Optional | description | | ||
|
||
### tkg-autoscaler Configuration | ||
|
||
| Value | Required/Optional | Description | | ||
|-------|-------------------|-------------| | ||
| `name` | Optional | description | | ||
|
||
## Usage Example | ||
|
||
The following is a basic guide for getting started with tkg-autoscaler. |
211 changes: 211 additions & 0 deletions
211
packages/tkg-autoscaler/bundle/config/upstream/tkg-autoscaler.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,211 @@ | ||
#@ load("@ytt:data", "data") | ||
|
||
#@ def autoscaler_volume_name(): | ||
#@ return "{}-cluster-autoscaler-volume".format(data.values.CLUSTER_NAME) | ||
#@ end | ||
|
||
#@ def autoscaler_kubeconfig_mount_path(): | ||
#@ return "/mnt/{}-kubeconfig".format(data.values.CLUSTER_NAME) | ||
#@ end | ||
|
||
#@ def autoscaler_args(): | ||
#@ args = ["--cloud-provider=clusterapi"] | ||
#@ args.append("--v=4") | ||
#@ args.append("--clusterapi-cloud-config-authoritative") | ||
#@ args.append("--kubeconfig=" + autoscaler_kubeconfig_mount_path() + "/value") | ||
#@ args.append("--node-group-auto-discovery=clusterapi:clusterName=" + data.values.CLUSTER_NAME) | ||
#@ args.append("--scale-down-delay-after-add=" + data.values.AUTOSCALER_SCALE_DOWN_DELAY_AFTER_ADD) | ||
#@ args.append("--scale-down-delay-after-delete=" + data.values.AUTOSCALER_SCALE_DOWN_DELAY_AFTER_DELETE) | ||
#@ args.append("--scale-down-delay-after-failure=" + data.values.AUTOSCALER_SCALE_DOWN_DELAY_AFTER_FAILURE) | ||
#@ args.append("--scale-down-unneeded-time=" + data.values.AUTOSCALER_SCALE_DOWN_UNNEEDED_TIME) | ||
#@ args.append("--max-node-provision-time=" + data.values.AUTOSCALER_MAX_NODE_PROVISION_TIME) | ||
#@ args.append("--max-nodes-total=" + "{}".format(data.values.AUTOSCALER_MAX_NODES_TOTAL)) | ||
#@ return args | ||
#@ end | ||
|
||
#@ if data.values.TKG_CLUSTER_ROLE == "workload" and data.values.PROVIDER_TYPE != "tkg-service-vsphere": | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: #@ "{}-cluster-autoscaler".format(data.values.CLUSTER_NAME) | ||
namespace: #@ data.values.NAMESPACE | ||
labels: | ||
app: #@ "{}-cluster-autoscaler".format(data.values.CLUSTER_NAME) | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: #@ "{}-cluster-autoscaler".format(data.values.CLUSTER_NAME) | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: #@ "{}-cluster-autoscaler".format(data.values.CLUSTER_NAME) | ||
spec: | ||
containers: | ||
- image: tkg-autoscaler:latest | ||
name: #@ "{}-cluster-autoscaler".format(data.values.CLUSTER_NAME) | ||
volumeMounts: | ||
- name: #@ autoscaler_volume_name() | ||
mountPath: #@ autoscaler_kubeconfig_mount_path() | ||
readOnly: true | ||
command: | ||
- /cluster-autoscaler | ||
args: #@ autoscaler_args() | ||
volumes: | ||
- name: #@ autoscaler_volume_name() | ||
secret: | ||
secretName: #@ "{}-kubeconfig".format(data.values.CLUSTER_NAME) | ||
serviceAccountName: #@ "{}-autoscaler".format(data.values.CLUSTER_NAME) | ||
terminationGracePeriodSeconds: 10 | ||
tolerations: | ||
- effect: NoSchedule | ||
key: node-role.kubernetes.io/master | ||
--- | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: #@ "{}-autoscaler-workload".format(data.values.CLUSTER_NAME) | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: cluster-autoscaler-workload | ||
subjects: | ||
- kind: ServiceAccount | ||
name: #@ "{}-autoscaler".format(data.values.CLUSTER_NAME) | ||
namespace: #@ data.values.NAMESPACE | ||
--- | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: #@ "{}-autoscaler-management".format(data.values.CLUSTER_NAME) | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: cluster-autoscaler-management | ||
subjects: | ||
- kind: ServiceAccount | ||
name: #@ "{}-autoscaler".format(data.values.CLUSTER_NAME) | ||
namespace: #@ data.values.NAMESPACE | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: #@ "{}-autoscaler".format(data.values.CLUSTER_NAME) | ||
namespace: #@ data.values.NAMESPACE | ||
--- | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: cluster-autoscaler-workload | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- persistentvolumeclaims | ||
- persistentvolumes | ||
- pods | ||
- replicationcontrollers | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- nodes | ||
verbs: | ||
- get | ||
- list | ||
- update | ||
- watch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods/eviction | ||
verbs: | ||
- create | ||
- apiGroups: | ||
- policy | ||
resources: | ||
- poddisruptionbudgets | ||
verbs: | ||
- list | ||
- watch | ||
- apiGroups: | ||
- storage.k8s.io | ||
resources: | ||
- csinodes | ||
- storageclasses | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- batch | ||
resources: | ||
- jobs | ||
verbs: | ||
- list | ||
- watch | ||
- apiGroups: | ||
- apps | ||
resources: | ||
- daemonsets | ||
- replicasets | ||
- statefulsets | ||
verbs: | ||
- list | ||
- watch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- events | ||
verbs: | ||
- create | ||
- patch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- configmaps | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- update | ||
- apiGroups: | ||
- coordination.k8s.io | ||
resources: | ||
- leases | ||
verbs: | ||
- create | ||
- get | ||
- update | ||
--- | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: cluster-autoscaler-management | ||
rules: | ||
- apiGroups: | ||
- cluster.x-k8s.io | ||
resources: | ||
- machinedeployments | ||
- machines | ||
- machinesets | ||
verbs: | ||
- get | ||
- list | ||
- update | ||
- watch | ||
- patch | ||
- apiGroups: | ||
- cluster.x-k8s.io | ||
resources: | ||
- machinedeployments/scale | ||
- machinesets/scale | ||
verbs: | ||
- get | ||
- update | ||
|
||
#@ end |
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,17 @@ | ||
#@data/values | ||
|
||
#@overlay/match-child-defaults missing_ok=True | ||
--- | ||
|
||
#! User configurable values for tkg-autoscaler | ||
|
||
CLUSTER_NAME: | ||
NAMESPACE: | ||
AUTOSCALER_MAX_NODES_TOTAL: "0" | ||
AUTOSCALER_SCALE_DOWN_DELAY_AFTER_ADD: "10m" | ||
AUTOSCALER_SCALE_DOWN_DELAY_AFTER_DELETE: "10s" | ||
AUTOSCALER_SCALE_DOWN_DELAY_AFTER_FAILURE: "3m" | ||
AUTOSCALER_SCALE_DOWN_UNNEEDED_TIME: "10m" | ||
AUTOSCALER_MAX_NODE_PROVISION_TIME: "15m" | ||
TKG_CLUSTER_ROLE: | ||
PROVIDER_TYPE: |
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,6 @@ | ||
apiVersion: kbld.k14s.io/v1alpha1 | ||
kind: Config | ||
overrides: | ||
#! tkg-autoscaler | ||
- image: tkg-autoscaler:latest | ||
newImage: "" |
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,14 @@ | ||
apiVersion: data.packaging.carvel.dev/v1alpha1 | ||
kind: PackageMetadata | ||
metadata: | ||
name: tkg-autoscaler.tanzu.vmware.com | ||
namespace: default | ||
spec: | ||
displayName: "tkg-autoscaler" | ||
longDescription: "Autoscaler package for tkg clusters" | ||
shortDescription: "Defines the autoscaler resources for Tanzu" | ||
providerName: VMware | ||
maintainers: | ||
- name: "Sudarshan Aji" | ||
categories: | ||
- "clusterclass" |
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,25 @@ | ||
apiVersion: data.packaging.carvel.dev/v1alpha1 | ||
kind: Package | ||
metadata: | ||
name: tkg-autoscaler.tanzu.vmware.com | ||
namespace: default | ||
spec: | ||
refName: tkg-autoscaler.tanzu.vmware.com | ||
version: latest | ||
licenses: | ||
- "Apache 2.0" | ||
template: | ||
spec: | ||
fetch: | ||
- imgpkgBundle: | ||
image: # Get this value by pushing to your OCI Registry | ||
template: | ||
- ytt: | ||
paths: | ||
- config/ | ||
- kbld: | ||
paths: | ||
- "-" | ||
- .imgpkg/images.yml | ||
deploy: | ||
- kapp: {} |
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,3 @@ | ||
apiVersion: vendir.k14s.io/v1alpha1 | ||
directories: null | ||
kind: LockConfig |
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,3 @@ | ||
apiVersion: vendir.k14s.io/v1alpha1 | ||
kind: Config | ||
minimumRequiredVersion: 0.12.0 |