# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['eksupgrade', 'eksupgrade.models', 'eksupgrade.src']

package_data = \
{'': ['*'], 'eksupgrade.src': ['S3Files/*']}

install_requires = \
['boto3>=1.26.94,<2.0.0',
 'kubernetes>=21.0.0,<25.0.0',
 'packaging>=21.0,<22.0',
 'typer[all]>=0.7.0,<0.8.0']

entry_points = \
{'console_scripts': ['eksupgrade = eksupgrade.cli:app']}

setup_kwargs = {
    'name': 'eksupgrade',
    'version': '0.8.1',
    'description': 'The Amazon EKS cluster upgrade utility',
    'long_description': '# Amazon EKS Upgrade Utility\n\n<p align="center">\n<a href="https://github.com/aws-samples/eks-cluster-upgrade/actions/workflows/validate.yaml"><img alt="Validation Status" src="https://github.com/aws-samples/eks-cluster-upgrade/actions/workflows/validate.yaml/badge.svg?branch=main&event=push"></a>\n<a href="https://github.com/aws-samples/eks-cluster-upgrade/actions/workflows/e2e-test.yaml"><img alt="E2E Cluster Upgrade" src="https://github.com/aws-samples/eks-cluster-upgrade/actions/workflows/e2e-test.yaml/badge.svg?branch=main"></a>\n<a href="https://codecov.io/github/aws-samples/eks-cluster-upgrade?branch=main"><img alt="Coverage Status" src="https://codecov.io/github/aws-samples/eks-cluster-upgrade/coverage.svg?branch=main"></a>\n<a href="https://pypi.org/project/eksupgrade/"><img alt="PyPI" src="https://img.shields.io/pypi/v/eksupgrade"></a>\n<a href="https://pepy.tech/project/eksupgrade"><img alt="Downloads" src="https://pepy.tech/badge/eksupgrade"></a>\n</p>\n\nAmazon EKS cluster upgrade is a utility that automates the upgrade process for Amazon EKS clusters.\n\n## Process\n\nThe process for upgrading an Amazon EKS cluster using `eksupgrade` consists of primarily of three parts:\n\n1. Perform pre-flight checks prior to upgrading the cluster\n2. Upgrade the cluster\n3. Evaluate the cluster after upgrade\n\n### Pre-Flight Checks\n\nThere are a number of version compatibility constraints, health checks, etc., before a cluster can successfully be upgraded. `eksupgrade` performs the following pre-flight checks:\n\n1. Target Version Compatibility Check - Since any cluster in EKS is always allowed to upgrade to one version above and not beyond, a check for the target version is done as with each upgrade there are a lot of configuration changes and upgrading directly to a higher version can lead to breakdown of the services being provided by it.\n2. Customer Management Key - A cluster might have a CMK Key associated with it, so it is essential to verify if the same exists in user\'s account before carrying out the upgrade.\n3. Security Group - Every cluster has a security group associated with it to restrict and allow the flow of traffic across it, and therefore it has to be verified whether it exists in the user\'s VPC or not.\n4. Node group and worker node detail - EKS cluster supports multiple types of node groups. So for the purpose of upgrade, their kubelet version compatibility has to be checked to proceed with the upgrade step.\n5. Subnets - A minimum of 4-5 free IPs are required when doing a cluster upgrade to launch new nodes and node groups with the old ones to keep the services of the cluster running while the upgrade is going on. So check on the existence of the free IPs is performed.\n6. Cluster Roles - There are a lot of important cluster roles required during the upgrade related to addons, nodes, and other components of the cluster without which the cluster upgrade cannot be executed successfully.\n7. Pod Security Policy - EKS privileged role has to be checked to be present with the current pod security policy. (deprecated in Kubernetes v1.21, and removed from Kubernetes in v1.25)\n8. Cluster addons - The cluster addons like kube-proxy, VPC CNI and CoreDNS are essential for running various services across the cluster. The parameters available on these addons which are customized by the users on the target cluster have to be captured while upgrading so that they are to added back to maintain service availability.\n9. Pod Disruption Budget - The existence of PDB has to be checked in the cluster, and minimum and maximum available with it has to be taken into account while upgrading.\n10. Horizontal Pod and Cluster Autoscaler - As the other components are upgraded to the compatible image version, a check is performed to see if Cluster or Horizontal Pod Autoscaler are present. They are reviewed to upgrade to a compatible version with respect to the control plane.\n\n### Cluster Upgrade\n\n1. Control plane upgrade - This is handled entirely by AWS once the version upgrade has been requested.\n2. Identification of Managed and Self-managed node - The worker nodes are identified as EKS managed and Self-managed to perform upgrade.\n3. Managed Node group update - Updates managed node group to the specified version.\n4. Self-managed Node group update\n   - Launch new nodes with upgraded version and wait until they require ready status for next step.\n   - Mark existing nodes as unschedulable.\n   - If pod disruption budget (PDB) is present then check for force eviction flag (--force) which is given by user, only then evict the pods or continue with the flow.\n\n## Pre-Requisites\n\nBefore running `eksupgrade`, you will need to have permission for both AWS and the Kubernetes cluster itself.\n\n1. Install `eksupgrade` locally:\n\n```sh\npip install eksupgrade\n```\n\n2. Ensure you have the necessary AWS permissions; an example policy of required permissions is listed below:\n\n```json\n{\n  "Version": "2012-10-17",\n  "Statement": [\n    {\n      "Sid": "iam",\n      "Effect": "Allow",\n      "Action": [\n        "iam:GetRole",\n        "sts:GetAccessKeyInfo",\n        "sts:GetCallerIdentity",\n        "sts:GetSessionToken"\n      ],\n      "Resource": "*"\n    },\n    {\n      "Sid": "ec2",\n      "Effect": "Allow",\n      "Action": [\n        "autoscaling:CreateLaunchConfiguration",\n        "autoscaling:Describe*",\n        "autoscaling:SetDesiredCapacity",\n        "autoscaling:TerminateInstanceInAutoScalingGroup",\n        "autoscaling:UpdateAutoScalingGroup",\n        "ec2:Describe*",\n        "ssm:*"\n      ],\n      "Resource": "*"\n    },\n    {\n      "Sid": "eks",\n      "Effect": "Allow",\n      "Action": [\n        "eks:Describe*",\n        "eks:List*",\n        "eks:UpdateAddon",\n        "eks:UpdateClusterVersion",\n        "eks:UpdateNodegroupVersion"\n      ],\n      "Resource": "*"\n    }\n  ]\n}\n```\n\n3. Update your local kubeconfig to authenticate to the cluster:\n\n```sh\naws eks update-kubeconfig --name <CLUSTER-NAME> --region <REGION>\n```\n\n## Usage\n\nTo view the arguments and options, run:\n\n```sh\neksupgrade --help\n```\n\n```sh\n Usage: eksupgrade [OPTIONS] CLUSTER_NAME CLUSTER_VERSION REGION\n\n Run eksupgrade against a target cluster.\n\n╭─ Arguments ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮\n│ *    cluster_name         TEXT  The name of the cluster to be upgraded [default: None] [required]                                                                                                                   │\n│ *    cluster_version      TEXT  The target Kubernetes version to upgrade the cluster to [default: None] [required]                                                                                                  │\n│ *    region               TEXT  The AWS region where the target cluster resides [default: None] [required]                                                                                                          │\n╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮\n│ --max-retry                                    INTEGER  The most number of times to retry an upgrade [default: 2]                                                                                                   │\n│ --force                 --no-force                      Force the upgrade (e.g. pod eviction with PDB) [default: no-force]                                                                                          │\n│ --preflight             --no-preflight                  Run pre-flight check without upgrade [default: no-preflight]                                                                                                │\n│ --parallel              --no-parallel                   Upgrade all nodegroups in parallel [default: no-parallel]                                                                                                   │\n│ --latest-addons         --no-latest-addons              Upgrade addons to the latest eligible version instead of default [default: no-latest-addons]                                                                │\n│ --disable-checks        --no-disable-checks             Disable the pre-flight and post-flight checks during upgrade scenarios [default: no-disable-checks]                                                         │\n│ --interactive           --no-interactive                If enabled, prompt the user for confirmations [default: interactive]                                                                                        │\n│ --version                                               Display the current eksupgrade version                                                                                                                      │\n│ --install-completion                                    Install completion for the current shell.                                                                                                                   │\n│ --show-completion                                       Show completion for the current shell, to copy it or customize the installation.                                                                            │\n│ --help                                                  Show this message and exit.                                                                                                                                 │\n╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n```\n## Support & Feedback\n\nThis project is maintained by AWS Solution Architects and Consultants. It is not part of an AWS service and support is provided best-effort by the maintainers. To post feedback, submit feature ideas, or report bugs, please use the [Issues section](https://github.com/aws-samples/eks-cluster-upgrade/issues) of this repo. If you are interested in contributing, please see the [Contribution guide](https://github.com/aws-samples/eks-cluster-upgrade/blob/main/CONTRIBUTING.md).\n\n## Security\n\nSee [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.\n\n## License\n\nThis library is licensed under the MIT-0 License. See the [LICENSE](LICENSE) file.\n',
    'author': 'EKS Upgrade Maintainers',
    'author_email': 'eks-upgrade-maintainers@amazon.com',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'None',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'entry_points': entry_points,
    'python_requires': '>=3.8,<4.0',
}


setup(**setup_kwargs)
