Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Adding scaffolding for the tkg-autoscaler package
Browse files Browse the repository at this point in the history
  • Loading branch information
saji-pivotal committed May 25, 2022
1 parent 05af520 commit 782557c
Show file tree
Hide file tree
Showing 10 changed files with 318 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/package-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ repositories:
version: latest
#! Gets replaced with imgpkg sha256 at build, this should be name:version
sha256: "tkg-clusterclass:latest"
- name: tkg-autoscaler
displayName: tkg-autoscaler
#! Relative path to package bundle
path: packages/management/tkg-autoscaler
domain: tanzu.vmware.com
version: latest
#! Gets replaced with imgpkg sha256 at build, this should be name:version
sha256: "tkg-autoscaler:latest"
- name: tkg-clusterclass-docker
displayName: tkg-clusterclass-docker
#! Relative path to package bundle
Expand Down
6 changes: 6 additions & 0 deletions packages/tkg-autoscaler/Makefile
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
25 changes: 25 additions & 0 deletions packages/tkg-autoscaler/README.md
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 packages/tkg-autoscaler/bundle/config/upstream/tkg-autoscaler.yaml
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
17 changes: 17 additions & 0 deletions packages/tkg-autoscaler/bundle/config/values.yaml
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:
6 changes: 6 additions & 0 deletions packages/tkg-autoscaler/kbld-config.yaml
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: ""
14 changes: 14 additions & 0 deletions packages/tkg-autoscaler/metadata.yaml
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"
25 changes: 25 additions & 0 deletions packages/tkg-autoscaler/package.yaml
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: {}
3 changes: 3 additions & 0 deletions packages/tkg-autoscaler/vendir.lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
apiVersion: vendir.k14s.io/v1alpha1
directories: null
kind: LockConfig
3 changes: 3 additions & 0 deletions packages/tkg-autoscaler/vendir.yml
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

0 comments on commit 782557c

Please # to comment.