Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/k8s-configuration/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

1.4.1
++++++++++++++++++
* Prepend bucket parameters with "bucket" keyword
* Fix some help text

1.4.0
++++++++++++++++++
* Add `--kind bucket` for creation of S3 bucket as source for fluxConfigurations
Expand Down
7 changes: 6 additions & 1 deletion src/k8s-configuration/azext_k8s_configuration/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
--name myconfig --scope cluster --namespace my-namespace \\
--kind bucket --url https://bucket-provider.minio.io \\
--bucket-name my-bucket --kustomization name=my-kustomization \\
--access-key my-access-key --secret-key my-secret-key
--bucket-access-key my-access-key --bucket-secret-key my-secret-key
"""

helps[
Expand All @@ -108,6 +108,11 @@
--cluster-name mycluster --cluster-type connectedClusters --name myconfig \\
--url https://github.com/Azure/arc-k8s-demo --branch main \\
--kustomization name=my-kustomization path=./my/new-path
- name: Update a Flux v2 Kubernetse configuration with Bucket Source Kind to connect insecurely
text: |-
az k8s-configuration flux update --resource-group my-resource-group \\
--cluster-name mycluster --cluster-type connectedClusters --name myconfig \\
--bucket-insecure
"""

helps[
Expand Down
20 changes: 10 additions & 10 deletions src/k8s-configuration/azext_k8s_configuration/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,23 @@ def load_arguments(self, _):
help="File path to known_hosts contents containing public SSH keys required to access private Git instances",
)
c.argument(
"access_key",
"bucket_access_key",
arg_group="Bucket Auth",
help="Access Key Id used to authenticate with the bucket url",
help="Access Key ID used to authenticate with the bucket",
)
c.argument(
"secret_key",
"bucket_secret_key",
arg_group="Bucket Auth",
help="Secret Key used to authenticate with the bucket url",
help="Secret Key used to authenticate with the bucket",
)
c.argument(
"bucket_name",
help="Name of the S3 bucket at the given url to connect to",
help="Name of the S3 bucket to sync",
)
c.argument(
"insecure",
"bucket_insecure",
arg_type=get_three_state_flag(),
help="Communicate with a bucket without TLS",
help="Communicate with a bucket without TLS. Default: false",
)
c.argument(
"local_auth_ref",
Expand All @@ -164,7 +164,7 @@ def load_arguments(self, _):
c.argument(
"suspend",
arg_type=get_three_state_flag(),
help="Suspend the reconciliation of the source and kustomizations associated with this configuration",
help="Suspend the reconciliation of the source and kustomizations associated with this configuration. Default: false",
)
c.argument(
"kustomization",
Expand Down Expand Up @@ -333,12 +333,12 @@ def load_arguments(self, _):
c.argument(
"prune",
arg_type=get_three_state_flag(),
help="Garbage collect resources deployed by the kustomization on the cluster",
help="Garbage collect resources deployed by the kustomization on the cluster. Default: false",
)
c.argument(
"force",
arg_type=get_three_state_flag(),
help="Re-create resources that cannot be updated on the cluster (i.e. jobs)",
help="Re-create resources that cannot be updated on the cluster (i.e. jobs). Default: false",
)

with self.argument_context("k8s-configuration flux kustomization delete") as c:
Expand Down
6 changes: 3 additions & 3 deletions src/k8s-configuration/azext_k8s_configuration/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@
"bucket_name",
"sync_interval",
"timeout",
"access_key",
"secret_key",
"insecure",
"bucket_access_key",
"bucket_secret_key",
"bucket_insecure",
"local_auth_ref",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ def create_config(
https_ca_cert_file=None,
known_hosts=None,
known_hosts_file=None,
access_key=None,
secret_key=None,
insecure=False,
bucket_access_key=None,
bucket_secret_key=None,
bucket_insecure=False,
suspend=False,
kustomization=None,
no_wait=False,
Expand Down Expand Up @@ -175,9 +175,9 @@ def create_config(
https_ca_cert_file=https_ca_cert_file,
known_hosts=known_hosts,
known_hosts_file=known_hosts_file,
access_key=access_key,
secret_key=secret_key,
insecure=insecure,
bucket_access_key=bucket_access_key,
bucket_secret_key=bucket_secret_key,
bucket_insecure=bucket_insecure,
)

# This update func is a generated update function that modifies
Expand All @@ -193,7 +193,7 @@ def create_config(

# Get the protected settings and validate the private key value
protected_settings = get_protected_settings(
ssh_private_key, ssh_private_key_file, https_key, secret_key
ssh_private_key, ssh_private_key_file, https_key, bucket_secret_key
)
if protected_settings and consts.SSH_PRIVATE_KEY_KEY in protected_settings:
validate_private_key(protected_settings["sshPrivateKey"])
Expand Down Expand Up @@ -256,9 +256,9 @@ def update_config(
https_ca_cert_file=None,
known_hosts=None,
known_hosts_file=None,
access_key=None,
secret_key=None,
insecure=None,
bucket_access_key=None,
bucket_secret_key=None,
bucket_insecure=None,
suspend=None,
kustomization=None,
no_wait=False,
Expand Down Expand Up @@ -293,9 +293,9 @@ def update_config(
https_ca_cert_file=https_ca_cert_file,
known_hosts=known_hosts,
known_hosts_file=known_hosts_file,
access_key=access_key,
secret_key=secret_key,
insecure=insecure,
bucket_access_key=bucket_access_key,
bucket_secret_key=bucket_secret_key,
bucket_insecure=bucket_insecure,
)

# This update func is a generated update function that modifies
Expand Down Expand Up @@ -324,7 +324,7 @@ def update_config(

# Get the protected settings and validate the private key value
protected_settings = get_protected_settings(
ssh_private_key, ssh_private_key_file, https_key, secret_key
ssh_private_key, ssh_private_key_file, https_key, bucket_secret_key
)
if protected_settings and consts.SSH_PRIVATE_KEY_KEY in protected_settings:
validate_private_key(protected_settings["sshPrivateKey"])
Expand Down Expand Up @@ -968,15 +968,17 @@ def __init__(self, **kwargs):
self.bucket_name = kwargs.get("bucket_name")
self.timeout = kwargs.get("timeout")
self.sync_interval = kwargs.get("sync_interval")
self.access_key = kwargs.get("access_key")
self.secret_key = kwargs.get("secret_key")
self.bucket_access_key = kwargs.get("bucket_access_key")
self.bucket_secret_key = kwargs.get("bucket_secret_key")
self.local_auth_ref = kwargs.get("local_auth_ref")
self.insecure = kwargs.get("insecure")
self.bucket_insecure = kwargs.get("bucket_insecure")

def validate(self):
super().validate_required_params(**self.kwargs)
validate_bucket_url(self.url)
if not ((self.access_key and self.secret_key) or self.local_auth_ref):
if not (
(self.bucket_access_key and self.bucket_secret_key) or self.local_auth_ref
):
raise RequiredArgumentMissingError(
consts.REQUIRED_BUCKET_VALUES_MISSING_ERROR,
consts.REQUIRED_BUCKET_VALUES_MISSING_HELP,
Expand All @@ -995,9 +997,9 @@ def bucket_updater(config):
bucket_name=self.bucket_name,
timeout_in_seconds=parse_duration(self.timeout),
sync_interval_in_seconds=parse_duration(self.sync_interval),
access_key=self.access_key,
access_key=self.bucket_access_key,
local_auth_ref=self.local_auth_ref,
insecure=self.insecure,
insecure=self.bucket_insecure,
)
config.source_kind = SourceKindType.BUCKET
return config
Expand All @@ -1018,9 +1020,9 @@ def bucket_patch_updater(config):
bucket_name=self.bucket_name,
timeout_in_seconds=parse_duration(self.timeout),
sync_interval_in_seconds=parse_duration(self.sync_interval),
access_key=self.access_key,
access_key=self.bucket_access_key,
local_auth_ref=self.local_auth_ref,
insecure=self.insecure,
insecure=self.bucket_insecure,
)
if swapped_kind:
self.validate()
Expand All @@ -1032,7 +1034,7 @@ def bucket_patch_updater(config):


def get_protected_settings(
ssh_private_key, ssh_private_key_file, https_key, secret_key
ssh_private_key, ssh_private_key_file, https_key, bucket_secret_key
):
protected_settings = {}
ssh_private_key_data = get_data_from_key_or_file(
Expand All @@ -1046,8 +1048,8 @@ def get_protected_settings(
if https_key:
protected_settings[consts.HTTPS_KEY_KEY] = to_base64(https_key)

if secret_key:
protected_settings[consts.BUCKET_SECRET_KEY_KEY] = to_base64(secret_key)
if bucket_secret_key:
protected_settings[consts.BUCKET_SECRET_KEY_KEY] = to_base64(bucket_secret_key)

# Return the protected settings dict if there are any values there
return protected_settings if len(protected_settings) > 0 else None
42 changes: 22 additions & 20 deletions src/k8s-configuration/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,49 @@

from codecs import open
from setuptools import setup, find_packages

try:
from azure_bdist_wheel import cmdclass
except ImportError:
from distutils import log as logger

logger.warn("Wheel is not available, disabling bdist_wheel hook")

VERSION = '1.4.0'
VERSION = "1.4.1"

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
CLASSIFIERS = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'License :: OSI Approved :: MIT License',
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"License :: OSI Approved :: MIT License",
]

DEPENDENCIES = ["pycryptodome~=3.9.8"]

with open('README.rst', 'r', encoding='utf-8') as f:
with open("README.rst", "r", encoding="utf-8") as f:
README = f.read()
with open('HISTORY.rst', 'r', encoding='utf-8') as f:
with open("HISTORY.rst", "r", encoding="utf-8") as f:
HISTORY = f.read()

setup(
name='k8s-configuration',
name="k8s-configuration",
version=VERSION,
description='Microsoft Azure Command-Line Tools K8s-configuration Extension',
description="Microsoft Azure Command-Line Tools K8s-configuration Extension",
# TODO: Update author and email, if applicable
author='Microsoft Corporation',
author_email='[email protected]',
url='https://github.com/Azure/azure-cli-extensions/tree/master/src/k8s-configuration',
long_description=README + '\n\n' + HISTORY,
license='MIT',
author="Microsoft Corporation",
author_email="[email protected]",
url="https://github.com/Azure/azure-cli-extensions/tree/master/src/k8s-configuration",
long_description=README + "\n\n" + HISTORY,
license="MIT",
classifiers=CLASSIFIERS,
packages=find_packages(),
install_requires=DEPENDENCIES,
package_data={'azext_k8s_configuration': ['azext_metadata.json']},
package_data={"azext_k8s_configuration": ["azext_metadata.json"]},
)
2 changes: 1 addition & 1 deletion testing/test/configurations/Flux.Bucket.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Describe 'Bucket Flux Configuration Testing' {
}

It 'Creates a configuration and checks that it onboards correctly' {
az k8s-configuration flux create -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type "connectedClusters" --kind bucket -u "http://52.190.35.89" --bucket-name flux -n $configurationName --scope cluster --namespace $configurationName --access-key test --secret-key test --no-wait
az k8s-configuration flux create -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type "connectedClusters" --kind bucket -u "http://52.190.35.89" --bucket-name flux -n $configurationName --scope cluster --namespace $configurationName --bucket-access-key test --bucket-secret-key test --no-wait
$? | Should -BeTrue

# Loop and retry until the configuration installs
Expand Down
2 changes: 1 addition & 1 deletion testing/test/configurations/Flux.CrossKind.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Describe 'Bucket Flux Configuration Testing' {
}

It 'Creates a configuration and checks that it onboards correctly' {
az k8s-configuration flux create -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type "connectedClusters" --kind bucket -u "http://52.190.35.89" --bucket-name flux -n $configurationName --scope cluster --namespace $configurationName --access-key test --secret-key test --no-wait
az k8s-configuration flux create -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type "connectedClusters" --kind bucket -u "http://52.190.35.89" --bucket-name flux -n $configurationName --scope cluster --namespace $configurationName --bucket-access-key test --bucket-secret-key test --no-wait
$? | Should -BeTrue

# Loop and retry until the configuration installs
Expand Down