Skip to content

Commit

Permalink
Merge pull request #6 from aws-samples/dev
Browse files Browse the repository at this point in the history
Major Updates - v2
  • Loading branch information
elamaran11 authored May 3, 2024
2 parents cb42a91 + ec2763c commit a04c115
Show file tree
Hide file tree
Showing 43 changed files with 1,682 additions and 986 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"rules": {
"perfectionist/sort-objects": "off",
"perfectionist/sort-classes": "off",
"perfectionist/sort-imports": "off",
"unicorn/no-static-only-class": "off"
},
"extends": ["oclif", "oclif-typescript", "prettier"]
}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@
node_modules
oclif.lock
oclif.manifest.json
*.tgz
**/unzipped-*/
*.iml
.idea

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.19.0
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
SHELL=bash
HELM_VERSION="3.8.1"
default: pack

check:
if [ -d "${HOME}/.nvm/.git" ]; then echo "nvm installed"; else echo "nvm not installed. Install it as instructed here: https://github.com/nvm-sh/nvm#install--update-script"; exit 1; fi

scrub:
rm -rf ./node_modules
rm -rf aws-sleek-transformer*gz

setup:
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod +x get_helm.sh
./get_helm.sh -v $(HELM_VERSION)
rm -rf get_helm.sh
NVM_DIR="$(HOME)/.nvm" && . "$(NVM_DIR)/nvm.sh" && nvm install
npm install

build:
npm run prepack
npm pack

install:
npm install -g $(shell ls aws-sleek-transformer*gz)
echo "Installed successfully, test by running: 'aws-sleek-transformer' --help "

publish:
npm publish --access public

pack: check scrub setup build install
260 changes: 148 additions & 112 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,163 +1,190 @@
Addons Transformer CLI for Amazon EKS
=====================================

<!-- toc -->
* [Usage](#usage)
* [Introduction](#introduction)
* [Pre-requisites](#pre-requisites)
* [Features](#features)
* [Installation](#installation)
* [Commands](#commands)
<!-- tocstop -->

## Introduction

Sleek Marketplace validator is solution provide pre-launch validations of the partner software on compatibility with Sleek guidelines, covering static and dynamic (deployment/runtime) aspects. This npm module does the following:

1. Installs project dependencies such as `kubectl`, `eksctl`, `helm` utilities to the terminal.
2. Grabs the following user inputs :
- Addon Name
- Helm Url of the Addon
- Addon version
- Deployment namespace
- Account id of the marketplace account
- AWS region
3. Authenticates to ECR Repo and downloads the helm chart from the specified Helm repo url.
4. Performs static validations to find occurrences of:
- `.Capabilities`
- `helm.sh/hook`
5. Sends the addon and the report of the validation to the AWS Marketplace team to start getting the addon listed on the
EKS console marketplace.


### Pre-requisites
Addons Transformer for Amazon EKS is a solution that provides pre-launch validations of the partner software based on
compatibility with [Amazon EKS Third Party Addon guidelines](https://docs.aws.amazon.com/marketplace/latest/userguide/container-product-policies.html#publishing-eks-add-on),
covering static and dynamic (deployment/runtime) aspects.

## Pre-requisites
To implement this solution, you need the following prerequisites:

* The [AWS Command Line Interface](http://aws.amazon.com/cli) (AWS CLI) [installed](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html). The AWS CLI is a unified tool to manage your AWS services.
* The [AWS Command Line Interface](http://aws.amazon.com/cli) (AWS CLI) [installed](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
The AWS CLI is a unified tool to manage your AWS services.
* AWS CLI default profile should be configured to access your AWS Account.
* [Node](https://nodejs.org/en/download/current/) version 18.12.1 or later.
* [NPM](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) version 8.19.2 or later.
* [Helm CLI](https://helm.sh/docs/intro/install/) to interact with helm charts.

## Quick-install

You can run `make` or execute `install.sh` to build this project and install the resulting library. In this case only the following are required:

* The [AWS Command Line Interface](http://aws.amazon.com/cli) (AWS CLI) [installed](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
The AWS CLI is a unified tool to manage your AWS services.
* [NVM](https://github.com/nvm-sh/nvm#install--update-script)

Both of these install the suitable Node, Npm and Helm versions required.

## Cloud Shell Installation
To quickly get started with this transformer, you can leverage CloudShell in the AWS Console. Some prerequisites you need:
* Access to the helm chart to pull it
* Install the Helm CLI in CloudShell using the following commands:
```shell
$ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
$ chmod 700 get_helm.sh
$ ./get_helm.sh
```
* A GitHub token as required by [The GitHub Service](README.md#request-submission-for-onboarding-the-add-on-to-the-program)

To use this CLI in CloudShell,
* Log into the AWS Console with a role that has access to the location of the helm chart
* If the chart is in a private ECR repo, ensure the role can pull from that repo.
* If the chart is in a public repo, ensure that there aren't any permissions restricting access to the public domain
* Use the npm install command to directly install the CLI into the shell: `npm i -g addons-transformer-for-amazon-eks`
* Follow steps in [the Helm chart validation section](README.md#helm-chart-validation) for all other questions.
## Features
This npm module has the following features:
### Helm chart validation
This NPM module accepts two kinds of input:
- CLI Args as described in the [Commands](README.md#commands) section
- Input file as described in [AddOn Submission](#request-submission-for-onboarding-the-add-on-to-the-program)
The module then performs static validation to attempt to find the following:
- Finding occurrences of unsupported `.Capabilities`
- Templates creating `helm.sh/hook`
- Use of `.Release.Service`
- Use of helm lookup function
- Dependencies external to the main chart
- Errors running `helm lint` see [lint command](#helm-lint-command) below
- Errors running `helm template...` (see [template command](#helm-template-command) below
If the chart is not in a public registry, login on it in advance is necessary, for example, for login on ECR:
```shell
export AWS_ACCOUNT=<Registry account>
export AWS_REGION=<Registry region>
export CHART_NAME=<Helm chart name>
export ECR_HELM_REPOSITORY=${AWS_ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/${CHART_NAME}
aws ecr get-login-password --region eu-west-1 | helm registry login --username AWS --password-stdin ${ECR_HELM_REPOSITORY%%/*}
```
#### Helm lint command
```shell
helm lint --strict --with-subcharts $CHART_LOCATION
```
#### Helm template command
```shell
helm template $CHART_NAME $CHART_LOCATION
--set k8version=$KUBERNETES_VERSION
--kube-version $KUBERNETES_VERSION
--namespace $ADDON_NAMESPACE
--include-crds
--no-hooks
```
### Request submission for onboarding the add-on to the program
This functionality creates a GitHub issue in the onboarding repository for starting the
process. As input, it takes the path to a `yaml` template that should contain the vendor,
product and the add-on required information. The json-schema for its creation can be found
in this repo [schema](./schema/onboarding.schema.json) and an example in the [doc/examples](./doc/examples/onboarding.example.yaml)
directory.
For validation the template, it supports the flag `--dry-run` that prevents the issue creation.
As it will run locally `aws-sleek-transformer validate` passing the file as input, it needs to be able to download the
chart.
# Usage
## Installation
<!-- usage -->
```sh-session
$ npm install -g addons-transformer-for-amazon-eks
$ addons-transformer-for-amazon-eks COMMAND
running command...
$ addons-transformer-for-amazon-eks (--version)
addons-transformer-for-amazon-eks/0.0.1 darwin-arm64 node-v20.8.0
addons-transformer-for-amazon-eks/0.0.6 darwin-arm64 node-v20.10.0
$ addons-transformer-for-amazon-eks --help [COMMAND]
USAGE
$ addons-transformer-for-amazon-eks COMMAND
...
```
<!-- usagestop -->
# Commands
## Commands
<!-- commands -->
* [`addons-transformer-for-amazon-eks configure`](#addons-transformer-for-amazon-eks-configure)
* [`addons-transformer-for-amazon-eks submit`](#addons-transformer-for-amazon-eks-submit)
* [`addons-transformer-for-amazon-eks validate`](#addons-transformer-for-amazon-eks-validate)
* [`addons-transformer-for-amazon-eks create-issue FILE`](#addons-transformer-for-amazon-eks-create-issue-file)
* [`addons-transformer-for-amazon-eks validate [HELMURL]`](#addons-transformer-for-amazon-eks-validate-helmurl)
## `addons-transformer-for-amazon-eks configure`
## `addons-transformer-for-amazon-eks create-issue FILE`
Sets up the Sleek CLI to work with a given helm chart
Creates a Github Issue based in the input file
```
USAGE
$ addons-transformer-for-amazon-eks configure [--addonName <value>] [--addonVersion <value>] [--helmUrl
<value>] [--marketplaceId <value>] [--namespace <value>] [--region <value>]
FLAGS
--addonName=<value> Name of the addon
--addonVersion=<value> Version of the addon
--helmUrl=<value> Helm URL of the addon
--marketplaceId=<value> Marketplace AWS Account ID
--namespace=<value> Namespace of the addon
--region=<value> AWS Region
DESCRIPTION
Sets up the Sleek CLI to work with a given helm chart
Extracts information from the environment to populate information required for the Sleek CLI to function. If
certain information is not found, prompts the user for it and asks them to validate the information extracted from
the environment.
This information is stored ~/.sleek/config.json
Each of these configurations can be edited by passing the exact addon name and version.
The CLI requires the following:
* AWS Region
* Marketplace AWS Account ID
* Addon Name
* Addon Version
* Addon Helm Url
* Deployment Namespace
Each of these can be passed as flags to this command with the following flags:
* --region
* --marketplace_id
* --addon_name
* --addon_version
* --helm_url
* --namespace
$ addons-transformer-for-amazon-eks create-issue FILE [-d] [--file <value>]
EXAMPLES
$ addons-transformer-for-amazon-eks configure
```

_See code: [src/commands/configure.ts](https://github.com/aws-samples/addons-transformer-for-amazon-eks/blob/v0.0.1/src/commands/configure.ts)_

## `addons-transformer-for-amazon-eks submit`

Uses the pre-existing configurations to submit the addon to the AWS marketplace

```
USAGE
$ addons-transformer-for-amazon-eks submit [--addonName <value>] [--addonVersion <value>]
ARGUMENTS
FILE Path to add-on input file
FLAGS
--addonName=<value> Name of the addon to submit
--addonVersion=<value> Version of the addon to submit
-d, --dryRun Validates the input file schema without creating the issue nor validating the chart
DESCRIPTION
Uses the pre-existing configurations to submit the addon to the AWS marketplace
Creates a Github Issue based in the input file
Sends the selected addon, version to the marketplace for final submission and upload it to Project Sleek.
It reads from the addons stored in the config: ~/.sleek/config.json and presents them as options to the user to
submit.
This creates a Github Issue on the Sleek repository.
The CLI requires the configure command to be run before hand to ensure there are correct configurations for each of
the addons.
This command requires the following:
* Addon Name - as used in the configure command
* Addon Version - as used in the configure command
If no flags are provided, the CLI will launch an interactive menu which let's you select which addon to submit to
the marketplace.
It will validate the input file to match the schema
EXAMPLES
$ addons-transformer-for-amazon-eks submit
$ addons-transformer-for-amazon-eks create-issue filename
```
_See code: [src/commands/submit.ts](https://github.com/aws-samples/addons-transformer-for-amazon-eks/blob/v0.0.1/src/commands/submit.ts)_
_See code: [src/commands/create-issue.ts](https://github.com/aws-samples/addons-transformer-for-amazon-eks/blob/v0.0.6/src/commands/create-issue.ts)_
## `addons-transformer-for-amazon-eks validate`
## `addons-transformer-for-amazon-eks validate [HELMURL]`
Validates a given addon from the configuration provided through the 'configure' command
Validates the addon after pulling it from the helm repository.
```
USAGE
$ addons-transformer-for-amazon-eks validate [--addonName <value>] [--addonVersion <value>]
$ addons-transformer-for-amazon-eks validate [HELMURL] [-d <value> | [-f <value> | --helmUrl <value>] | ]
[-r <value> | | ] [-p <value> | | ] [-v <value> | ] [--addonName <value>] [-n <value>] [--k8sVersions <value>]
[--skipHooks] [--skipReleaseService]
ARGUMENTS
HELMURL Fully qualified Helm URL of the addon
FLAGS
--addonName=<value> Name of the addon to validate
--addonVersion=<value> Version of the addon to validate
-d, --directory=<value> Path to the local addon folder
-f, --file=<value> Path to add-on input file
-n, --addonNamespace=<value> Add-on namespace
-p, --protocol=<value> Protocol of the helm hosting to use
-r, --helmRepo=<value> URL of the helm repo containg protocol and repo
-v, --version=<value> Version of the addon to validate
--addonName=<value> Name of the addon
--helmUrl=<value> Fully qualified URL of the Repo including version tag
--k8sVersions=<value> Comma separated list of supported kubernetes versions
--skipHooks Skip helm hooks validation
--skipReleaseService Skip .Release.Service occurrences
DESCRIPTION
Validates a given addon from the configuration provided through the 'configure' command
Validates the addon after pulling it from the helm repository.
This performs pre-launch validations of the partner software on compatibility with Sleek guidelines, covering static
Expand All @@ -166,18 +193,27 @@ DESCRIPTION
Runs the static analysis to find occurrences of:
* .Capabilities
* helm.sh/hook
This command requires the "configure" command to have been run, it needs:
* Helm URL
to be configured correctly.
* external helm dependencies
It will perform a static validation on the device and then give you the option to submit it to the marketplace for
runtime and further validation before it can be included in the EKS Console marketplace.
The command can accept two different formats of inputs:
* Fully qualified Helm URL to download
* Deconstructed URL that requires Protocol, Repo, and Version to pull
EXAMPLES
$ addons-transformer-for-amazon-eks validate
$ addons-transformer-for-amazon-eks validate oci://12345678901.dkr.ecr.us-east-2.amazonaws.com/example-charts:x.x.x
$ addons-transformer-for-amazon-eks validate -r 12345678901.dkr.ecr.us-east-2.amazonaws.com/example-charts -p oci -v x.x.x
$ addons-transformer-for-amazon-eks validate -f ./input.yaml
$ addons-transformer-for-amazon-eks validate -d ./addon-folder
$ addons-transformer-for-amazon-eks validate --help
```
_See code: [src/commands/validate.ts](https://github.com/aws-samples/addons-transformer-for-amazon-eks/blob/v0.0.1/src/commands/validate.ts)_
_See code: [src/commands/validate.ts](https://github.com/aws-samples/addons-transformer-for-amazon-eks/blob/v0.0.6/src/commands/validate.ts)_
<!-- commandsstop -->
9 changes: 9 additions & 0 deletions aws-sleek-transformer.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Loading

0 comments on commit a04c115

Please sign in to comment.