### Get InstallPlans Source: https://github.com/azure/azure-service-operator/blob/main/docs/operator-bundle/testing-and-releasing.md Use this command to retrieve all install plans in the operators namespace. ```sh k get -n operators installplans ``` -------------------------------- ### Install asoctl on Linux Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/tools/asoctl.md Installs the downloaded asoctl binary to the system's PATH, making it available globally. Requires root privileges. ```bash $ sudo install -o root -g root -m 0755 asoctl /usr/local/bin/asoctl ``` -------------------------------- ### Install ASO with Global Credentials via Helm Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/guide/authentication/credential-format.md Use these Helm arguments to set global credentials during the initial installation of ASO. This method is suitable for first-time installations. ```bash helm upgrade --install --devel aso2 aso2/azure-service-operator \ --create-namespace \ --namespace=azureserviceoperator-system \ --set azureSubscriptionID=$AZURE_SUBSCRIPTION_ID \ --set azureTenantID=$AZURE_TENANT_ID \ --set azureClientID=$AZURE_CLIENT_ID \ --set useWorkloadIdentityAuth=true \ --set crdPattern='resources.azure.com/*;containerservice.azure.com/*;keyvault.azure.com/*;managedidentity.azure.com/*;eventhub.azure.com/*' ``` -------------------------------- ### Run Hugo Server Locally Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/README.md Use this command to start the Hugo development server. Ensure Hugo is installed first. ```sh hugo server ``` -------------------------------- ### Install ASO using asoctl Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/contributing/create-a-new-release.md Use asoctl to export the template and apply it to the cluster using kubectl. This installs the new release of ASO. ```bash ./asoctl export template --version v2.18.0 --crd-pattern "resources.azure.com/*;network.azure.com/*" | kubectl apply --server-side=true -f - ``` -------------------------------- ### Install ASO with Global Credentials via Helm Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/guide/authentication/credential-format.md Use these Helm arguments to install ASO for the first time with global Azure credentials. Ensure environment variables for subscription ID, client ID, and tenant ID are set. ```bash helm upgrade --install --devel aso2 aso2/azure-service-operator \ --create-namespace \ --namespace=azureserviceoperator-system \ --set azureSubscriptionID=$AZURE_SUBSCRIPTION_ID \ --set azureClientID=${IDENTITY_CLIENT_ID} \ --set crdPattern='resources.azure.com/*;containerservice.azure.com/*;keyvault.azure.com/*;managedidentity.azure.com/*;eventhub.azure.com/*' ``` -------------------------------- ### Install ASO with Global Credentials via Helm Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/guide/authentication/credential-format.md Use these Helm arguments to set global credentials when installing ASO for the first time. Ensure environment variables are set beforehand. ```bash helm upgrade --install --devel aso2 aso2/azure-service-operator \ --create-namespace \ --namespace=azureserviceoperator-system \ --set azureSubscriptionID=$AZURE_SUBSCRIPTION_ID \ --set azureTenantID=$AZURE_TENANT_ID \ --set azureClientID=$AZURE_CLIENT_ID \ --set azureClientCertificatePassword=$AZURE_CLIENT_CERTIFICATE_PASSWORD \ --set crdPattern='resources.azure.com/*;containerservice.azure.com/*;keyvault.azure.com/*;managedidentity.azure.com/*;eventhub.azure.com/*' ``` -------------------------------- ### Install ASO with Global Credentials via Helm Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/guide/authentication/credential-format.md Use these Helm arguments to install ASO for the first time with global credentials. Ensure environment variables like AZURE_SUBSCRIPTION_ID, IDENTITY_RESOURCE_ID, and IDENTITY_CLIENT_ID are set. ```bash helm upgrade --install --devel aso2 aso2/azure-service-operator \ --create-namespace \ --namespace=azureserviceoperator-system \ --set azureSubscriptionID=$AZURE_SUBSCRIPTION_ID \ --set aadPodIdentity.enable=true \ --set aadPodIdentity.azureManagedIdentityResourceId=${IDENTITY_RESOURCE_ID} \ --set azureClientID=${IDENTITY_CLIENT_ID} \ --set crdPattern='resources.azure.com/*;containerservice.azure.com/*;keyvault.azure.com/*;managedidentity.azure.com/*;eventhub.azure.com/*' ``` -------------------------------- ### Generic Controller Reconciliation Loop Example Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/design/type-references-and-ownership.md This Go code demonstrates a generic controller reconciliation loop. It shows how to load an object, retrieve owner details, interact with Azure to get resource state, transform objects for ARM, and perform updates. Error handling is omitted for brevity. ```go // Example usage -- error handling elided for brevity func (gr *GenericReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { scheme := ... gvk := ... client := ... // Load the object from etcd obj := scheme.New(gvk) resource := client.Get(req.NamespacedName, obj) // Get the owner details armResource := obj.(ARMResource) ownerRef := armResource.Owner() // Perform a get from Azure to see current resource state armId := helpers.GetArmId(resource) objFromAzure := scheme.new(gvk) // We need to provide the empty type to deserialize into // Somehow construct a new object of type etcdObject if armTransformer, ok := objFromAzure.(ARMTransformer); ok { result := armTransformer.ToArm("") // This just converts from an empty kube shape to an empty arm shape armClient.GetIt(armId, result) armTransformer.FromArm(ownerRef, result) } // Perform a put to update resource state // Walk the owner hierarchy (assuming owner has no owner here for simplicity) to build owner name ownerGvk := ownerRef.ToGvk() owner := scheme.New(ownerGvk) ownerArmResource := owner.(ARMResource) ownerId := owner.Name() var toSerialize interface{} toSerialize = resource if armTransformer, ok := toSerialize.(ARMTransformer); ok { toSerialize = armTransformer.ToArm(ownerArmId) } json := json.Marshal(toSerialize) armClient.SendIt(json) } ``` -------------------------------- ### Create Kind Cluster and Install Chart Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/contributing/create-a-new-release.md Use this task to create a local Kind cluster and install the Azure Service Operator chart. ```bash task controller:kind-create-workloadidentity-local-helm ``` -------------------------------- ### Install ASO with Global Credentials via Helm Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/guide/authentication/credential-format.md Use these Helm arguments to set global Azure credentials when installing ASO for the first time. Ensure your environment variables are set. ```bash helm upgrade --install --devel aso2 aso2/azure-service-operator \ --create-namespace \ --namespace=azureserviceoperator-system \ --set azureSubscriptionID=$AZURE_SUBSCRIPTION_ID \ --set azureTenantID=$AZURE_TENANT_ID \ --set azureClientID=$AZURE_CLIENT_ID \ --set azureClientSecret=$AZURE_CLIENT_SECRET \ --set crdPattern='resources.azure.com/*;containerservice.azure.com/*;keyvault.azure.com/*;managedidentity.azure.com/*;eventhub.azure.com/*' ``` -------------------------------- ### Edit InstallPlan Source: https://github.com/azure/azure-service-operator/blob/main/docs/operator-bundle/testing-and-releasing.md Edit an install plan to approve its installation by setting `spec.approved` to `true`. ```sh k edit -n operators installplans install- ``` -------------------------------- ### Argo Helm Installation Configuration Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/guide/diagnosing-problems/_index.md When installing ASO via Argo, ensure the 'repoURL' points to the raw GitHub content of the charts directory, not the Git repository itself. This is crucial for including autogenerated files necessary for installation. ```yaml apiVersion: argoproj.io/v1alpha1 kind: Application spec: source: repoURL: https://raw.githubusercontent.com/Azure/azure-service-operator/main/v2/charts targetRevision: v2.8.0 chart: azure-service-operator ``` ```yaml apiVersion: argoproj.io/v1alpha1 kind: Application spec: source: repoURL: https://github.com/Azure/azure-service-operator.git targetRevision: v2.8.0 path: v2/charts/azure-service-operator ``` -------------------------------- ### Create Subscription for Operator Installation Source: https://github.com/azure/azure-service-operator/blob/main/docs/operator-bundle/testing-and-releasing.md Define a Subscription resource to trigger OLM to install the operator from the test CatalogSource. Use 'installPlanApproval: Manual' for controlled upgrades and 'startingCSV' to specify the initial version. ```yaml apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: labels: operators.coreos.com/azure-service-operator.operators: "" name: my-azure-service-operator namespace: operators spec: channel: stable name: azure-service-operator source: aso-test sourceNamespace: olm installPlanApproval: Manual startingCSV: azure-service-operator.v ``` -------------------------------- ### Example: Adding Azure Synapse Workspace Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/contributing/add-a-new-code-generated-resource/run-the-code-generator.md A concrete example demonstrating the YAML configuration for adding the 'Workspace' resource for the 'synapse' group under the '2021-06-01' API version. This shows the practical application of the `$exportAs` and `$supportedFrom` directives. ```yaml synapse: 2021-06-01: Workspace: $exportAs: Workspace $supportedFrom: v2.0.0 ``` -------------------------------- ### Install Operator Lifecycle Manager (OLM) Source: https://github.com/azure/azure-service-operator/blob/main/docs/operator-bundle/testing-and-releasing.md Installs the Operator Lifecycle Manager (OLM) using a provided script. Ensure you are using the correct version specified in the script. ```bash curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.18.1/install.sh | bash -s v0.18.1 ``` -------------------------------- ### Check cert-manager Pod Status Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/getting-started/_index.md Verifies that the cert-manager pods have started successfully. This is a prerequisite for installing the operator. ```bash kubectl get pods -n cert-manager NAME READY STATUS RESTARTS AGE cert-manager-5597cff495-lmphj 1/1 Running 0 1m cert-manager-cainjector-bd5f9c764-gvxm4 1/1 Running 0 1m cert-manager-webhook-c4b5687dc-x66bj 1/1 Running 0 1m ``` -------------------------------- ### Copy and Update Sample Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/contributing/upgrade-resource-version/_index.md Create a new directory for the updated version and copy the existing sample file. Then, modify the copied file to reflect the new resource version. ```bash cd mongodb mkdir v1api20231115 cp v1api20210515/v1api20210515_databaseaccount.yaml v1api20231115/v1api20231115_databaseaccount.yaml ``` -------------------------------- ### Helm values.yaml for crdPattern Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/getting-started/_index.md Example of how to set the `crdPattern` variable in a Helm values file for installing the Azure Service Operator. ```yaml crdPattern: - resources.azure.com/* - containerservice.azure.com/* - keyvault.azure.com/* - managedidentity.azure.com/* - eventhub.azure.com/* ``` -------------------------------- ### Sample StorageAccount Default Implementation Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/design/defaulter-validator.md This sample shows how to implement the `Default` method for a StorageAccount resource, including calling a custom defaulting method. ```go // +kubebuilder:webhook:path=/mutate-microsoft-storage-infra-azure-com-v1alpha1api20190401-storageaccount,mutating=true,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=microsoft.storage.infra.azure.com,resources=storageaccounts,verbs=create;update,versions=v1alpha1api20190401,name=default.v1alpha1api20190401.storageaccounts.microsoft.storage.infra.azure.com,admissionReviewVersions=v1beta1 var _ admission.Validator = &StorageAccount{} // ValidateCreate validates the creation of the resource func (storageAccount *StorageAccount) ValidateCreate() error { validations := storageAccount.createValidations() var temp interface{} = storageAccount if runtimeValidator, ok := temp.(genruntime.Validator); ok { validations = append(validations, runtimeValidator.CreateValidations()...) } var errs []error for _, validation := range validations { err := validation() if err != nil { err = append(errs, err) } } return kerrors.NewAggregate(errs) } func (storageAccount *StorageAccount) createValidations() []func() error { return []func() error{ storageAccount.validateResourceReferences, } } func (storageAccount *StorageAccount) validateResourceReferences() error { refs, err := reflecthelpers.FindResourceReferences(&storageAccount.Spec) if err != nil { return err } return genruntime.ValidateResourceReferences(refs) } // ``` -------------------------------- ### Download and prepare asoctl Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/contributing/create-a-new-release.md Download the asoctl binary, decompress it, and make it executable. This tool is used to install the new release. ```bash curl -L https://github.com/Azure/azure-service-operator/releases/latest/download/asoctl-linux-amd64.gz -o asoctl.gz gunzip asoctl.gz chmod +x asoctl ``` -------------------------------- ### Get ASO Controller Pod Logs Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/guide/diagnosing-problems/_index.md Retrieve logs from the ASO controller manager pod. This is often the last step in diagnosing issues, especially setup problems or when CRDs are missing. ```bash kubectl logs -n azureserviceoperator-system --selector control-plane=controller-manager --container manager ``` -------------------------------- ### Configure ASOv2 CRD Pattern Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/guide/asov1-asov2-migration/_index.md When installing ASOv2, use the `--crdPattern` flag to specify which CRDs ASOv2 should manage. This example configures ASOv2 to manage storage accounts, resource groups, redis cache, cosmosdb, eventhubs, and SQL Azure resources. ```bash --set crdPattern='resources.azure.com/*;cache.azure.com/*;documentdb.azure.com/*;eventhub.azure.com/*;sql.azure.com/*;storage.azure.com/*' ``` -------------------------------- ### Apply sample resources Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/contributing/create-a-new-release.md Apply sample ResourceGroup and VirtualNetwork YAML files to test ASO's ability to create Azure resources and verify webhook functionality. ```bash kubectl apply -f v2/samples/resources/v1api/v1api20200601_resourcegroup.yaml kubectl apply -f v2/samples/network/v1api20240301/v1api20240301_virtualnetwork.yaml ``` -------------------------------- ### Add Helm Repository and Install Azure Service Operator (CMD) Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/getting-started/_index.md Adds the Azure Service Operator Helm repository and installs the operator using Helm. The `crdPattern` is specified for the installation. ```cmd C:\> helm repo add aso2 https://raw.githubusercontent.com/Azure/azure-service-operator/main/v2/charts C:\> helm upgrade --install aso2 aso2/azure-service-operator ^ --create-namespace ^ --namespace=azureserviceoperator-system ^ --set crdPattern=resources.azure.com/*;containerservice.azure.com/*;keyvault.azure.com/*;managedidentity.azure.com/*;eventhub.azure.com/* ``` -------------------------------- ### Add Helm Repository and Install Azure Service Operator (PowerShell) Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/getting-started/_index.md Adds the Azure Service Operator Helm repository and installs the operator using Helm. The `crdPattern` is specified for the installation. ```powershell PS> helm repo add aso2 https://raw.githubusercontent.com/Azure/azure-service-operator/main/v2/charts PS> helm upgrade --install aso2 aso2/azure-service-operator ` --create-namespace ` --namespace=azureserviceoperator-system ` --set crdPattern=resources.azure.com/*;containerservice.azure.com/*;keyvault.azure.com/*;managedidentity.azure.com/*;eventhub.azure.com/* ``` -------------------------------- ### GPUDriver Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/reference/containerservice/v20251002preview.md Indicates whether to install GPU drivers. Defaults to 'Install' if not specified. ```APIDOC ## GPUDriver ### Description Whether to install GPU drivers. When it's not specified, default is Install. ``` -------------------------------- ### Show asoctl import azure-resource help Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/tools/asoctl.md Displays the help information for the `asoctl import azure-resource` command, outlining its usage, supported authentication methods, and available flags. ```bash asoctl import azure-resource --help ``` -------------------------------- ### Install cert-manager Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/getting-started/_index.md Installs cert-manager on your Kubernetes cluster. Ensure cert-manager is running before proceeding. ```bash kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.14.1/cert-manager.yaml ``` -------------------------------- ### Download asoctl for Linux (ARM64) Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/tools/asoctl.md Download the asoctl binary for Linux ARM64 architecture. This is the first step in installing the CLI on Linux. ```bash $ curl -L https://github.com/Azure/azure-service-operator/releases/latest/download/asoctl-linux-arm64.gz -o asoctl.gz $ gunzip asoctl.gz ``` -------------------------------- ### Install cert-manager Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/contributing/create-a-new-release.md Install cert-manager on the kind cluster using the provided task. Cert-manager is a dependency for ASO. ```bash task controller:install-cert-manager ``` -------------------------------- ### Storage Conversion with Metadata Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/design/versioning/case-studies/fixed-storage-version/_index.md Illustrates how to automatically generate conversion methods by configuring metadata that details property renames. This approach simplifies the conversion logic for storage versions. ```go package v20170707 // *** Updated storage version *** import v1 // ConvertTo converts this Person to the Hub version. func (person *Person) ConvertToStorage(dest v1.Person) error { // ... elided properties ... if person.MailingAddress != nil { address := &storage.Location{} err := person.MailingAddress.ConvertToStorage(address) if err != nil { return err } dest.MailingAddress = address } if assignable, ok := person.(AssignableToPerson); ok { err := assignable.AssignTo(dest) if err != nill { return err } } return nil } // ConvertToStorage converts this Address to the hub storage version // ** Different parameter type for dest *** func (address *Address) ConvertToStorage(dest v1.Location) error { dest.Street = address.Street dest.City = address.City // *** Interface has been renamed too ** if assignable, ok := person.(AssignableToLocation); ok { err := assignable.AssignTo(dest) if err != nill { return err } } return nil } ``` -------------------------------- ### Create AKS Cluster and Install Operator Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/contributing/running-a-development-version.md This command creates an AKS cluster, an ACR, installs cert-manager, builds and pushes a local container image, and installs the operator. It requires AZURE_SUBSCRIPTION_ID to be set. The location can be specified using LOCATION=mylocation. ```bash task controller:aks-create-helm-install LOCATION=mylocation ``` -------------------------------- ### Download asoctl for Linux (AMD64) Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/tools/asoctl.md Download the asoctl binary for Linux AMD64 architecture. This is the first step in installing the CLI on Linux. ```bash $ curl -L https://github.com/Azure/azure-service-operator/releases/latest/download/asoctl-linux-amd64.gz -o asoctl.gz $ gunzip asoctl.gz ``` -------------------------------- ### Sample StorageAccount ValidateCreate Implementation Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/design/defaulter-validator.md This sample demonstrates the `ValidateCreate` method for a StorageAccount, including custom validation logic and aggregation of errors. ```go // +kubebuilder:webhook:path=/validate-microsoft-storage-infra-azure-com-v1alpha1api20190401-storageaccount,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=microsoft.storage.infra.azure.com,resources=storageaccounts,verbs=create;update,versions=v1alpha1api20190401,name=validate.v1alpha1api20190401.storageaccounts.microsoft.storage.infra.azure.com,admissionReviewVersions=v1beta1 var _ admission.Validator = &StorageAccount{} // ValidateCreate validates the creation of the resource func (storageAccount *StorageAccount) ValidateCreate() error { validations := storageAccount.createValidations() var temp interface{} = storageAccount if runtimeValidator, ok := temp.(genruntime.Validator); ok { validations = append(validations, runtimeValidator.CreateValidations()...) } var errs []error for _, validation := range validations { err := validation() if err != nil { err = append(errs, err) } } return kerrors.NewAggregate(errs) } func (storageAccount *StorageAccount) createValidations() []func() error { return []func() error{ storageAccount.validateResourceReferences, } } func (storageAccount *StorageAccount) validateResourceReferences() error { refs, err := reflecthelpers.FindResourceReferences(&storageAccount.Spec) if err != nil { return err } return genruntime.ValidateResourceReferences(refs) } // ``` -------------------------------- ### ARM Template Example for Synapse Workspace Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/contributing/add-a-new-code-generated-resource/before-you-begin.md An example of an ARM template snippet showing the 'type' and 'apiVersion' for a Synapse Workspace. ```json { "type": "Microsoft.Synapse/workspaces", "apiVersion": "2021-06-01", ... } ``` -------------------------------- ### Install cert-manager Source: https://github.com/azure/azure-service-operator/blob/main/docs/operator-bundle/testing-and-releasing.md Installs cert-manager, a Kubernetes certificate controller, using its official YAML manifest. Verify the version compatibility with your cluster. ```yaml k apply -f https://github.com/jetstack/cert-manager/releases/download/v1.18.2/cert-manager.yaml ``` -------------------------------- ### Install Per-Tenant Operator Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/guide/authentication/multitenant-deployment.md Installs a tenant-specific instance of the ASO operator. This configuration includes tenant-specific Azure credentials and target namespaces. ```bash helm upgrade --install --devel aso2 aso2/azure-service-operator \ --create-namespace \ --namespace=tenant1-system \ --set azureSubscriptionID=$AZURE_SUBSCRIPTION_ID \ --set azureTenantID=$AZURE_TENANT_ID \ --set azureClientID=$AZURE_CLIENT_ID \ --set azureClientSecret=$AZURE_CLIENT_SECRET \ --set multitenant.enable=true \ --set azureTargetNamespaces='{ns1,ns2,ns3}' \ --set azureOperatorMode=watchers ``` -------------------------------- ### Run ASO Development Container Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/contributing/developer-setup.md Starts a development container from the built image, mounting local directories and configuring environment variables for ASO development. ```bash docker run --env-file ~/work/envs.env --env HOSTROOT=$(git rev-parse --show-toplevel) -v $(git rev-parse --show-toplevel):/go/src -w /go/src -u $(id -u ${USER}):$(id -g ${USER}) --group-add $(stat -c '%g' /var/run/docker.sock) -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kube:/home/vscode/.kube -v $HOME/.azure/:/home/vscode/.azure/ --network=host -it asodev:latest /bin/bash ``` -------------------------------- ### Specify CRDs to Install via Helm Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/guide/crd-management.md Use the `crdPattern` value in `values.yaml` to specify which CRDs to install. Existing CRDs are always upgraded. ```yaml crdPattern: resources.azure.com/*;containerservice.azure.com/*;keyvault.azure.com/*;managedidentity.azure.com/*;eventhub.azure.com/* ``` -------------------------------- ### Run All Sample Tests and Create Recordings Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/contributing/add-a-new-code-generated-resource/create-a-sample.md Execute all sample tests and generate recordings for any missing ones. This command is used to ensure sample correctness against a live cluster. ```bash TEST_FILTER=Test_Samples_CreationAndDeletion task controller:test-integration-envtest ``` -------------------------------- ### Download asoctl for macOS (AMD64) Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/tools/asoctl.md Download the asoctl binary for macOS AMD64 architecture. This is the first step in installing the CLI on macOS. ```bash $ curl -L https://github.com/Azure/azure-service-operator/releases/latest/download/asoctl-darwin-amd64.gz -o asoctl.gz $ gunzip asoctl.gz ``` -------------------------------- ### Example Array Conversion (String) Source: https://github.com/azure/azure-service-operator/blob/main/v2/tools/generator/internal/conversions/README.md Demonstrates a typical conversion of a string slice from a source object to a destination object, including nil checks and explicit nil assignment. ```go if source.Aliases != nil { aliasList := make([]string, len(source.Aliases)) for aliasIndex, aliasItem := range source.Aliases { aliasItem := aliasItem aliasList[aliasIndex] = aliasItem } destination.Aliases = aliasList } else { destination.Aliases = nil } ``` -------------------------------- ### Bicep Template Example for Synapse Workspace Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/contributing/add-a-new-code-generated-resource/before-you-begin.md An example of a Bicep template snippet defining a Synapse Workspace with its Azure type and API version. ```bicep resource synapse 'Microsoft.Synapse/workspaces@2021-06-01' = { ... } ``` -------------------------------- ### Install Cluster-Wide Operator (Multi-Tenant) Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/guide/authentication/multitenant-deployment.md Installs the ASO operator in a cluster-wide configuration with multi-tenancy enabled. This sets up the core operator and webhook for multi-tenant operations. ```bash helm upgrade --install --devel aso2 aso2/azure-service-operator \ --create-namespace \ --namespace=azureserviceoperator-system \ --set multitenant.enable=true \ --set azureOperatorMode=webhooks \ --set crdPattern='resources.azure.com/*;containerservice.azure.com/*;keyvault.azure.com/*;managedidentity.azure.com/*;eventhub.azure.com/*' ``` -------------------------------- ### Import PostgreSQL Server using asoctl Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/tools/asoctl.md Use this command to import an existing Azure PostgreSQL server into your environment. Provide the full ARM ID of the server. Multiple ARM IDs can be specified. ```bash $ asoctl import azure-resource /subscriptions/[redacted]/resourceGroups/aso-rg/providers/Microsoft.DBforPostgreSQL/flexibleServers/aso-pg --output aso.yaml ``` -------------------------------- ### Get ASO Operator Pod Description Source: https://github.com/azure/azure-service-operator/blob/main/docs/troubleshooting.md Use this command to get a detailed description of the ASO operator pod, which can help in diagnosing crash loops. ```bash kubectl describe pod operators ``` -------------------------------- ### Autoscalesetting STATUS - start field Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/reference/insights/v1api20221001.md The 'start' field indicates the beginning time for a profile, formatted according to ISO 8601 standards. This field is required. ```APIDOC ## Autoscalesetting_STATUS ### Description Details about the status of an autoscaling setting. ### Fields #### start (string) - Required The start time for the profile in ISO 8601 format. ``` -------------------------------- ### Download asoctl for macOS (ARM64) Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/tools/asoctl.md Download the asoctl binary for macOS ARM64 architecture. This is the first step in installing the CLI on macOS. ```bash $ curl -L https://github.com/Azure/azure-service-operator/releases/latest/download/asoctl-darwin-arm64.gz -o asoctl.gz $ gunzip asoctl.gz ``` -------------------------------- ### Resource Claiming Logic Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/design/reconcile-interface.md This code demonstrates the logic for claiming a resource, which may involve adding finalizers or other resource-specific setup. ```go if r.NeedToClaimResource(user) { // TODO: This assumes we're requeing and doing the "stages" thing, which I am not sure if it makes sense to do for everybody anymore _, err := r.ClaimResource(ctx, log, user) if err != nil { return ctrl.Result{}, err } } ``` -------------------------------- ### ASOv1 Secret Owner Reference Example Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/guide/asov1-asov2-migration/_index.md An example of the `ownerReferences` section within a Kubernetes secret managed by ASOv1. This structure indicates the ASOv1 resource that owns the secret. ```yaml ownerReferences: - apiVersion: azure.microsoft.com/v1alpha1 blockOwnerDeletion: true controller: true kind: Eventhub name: eventhub-sample-1 uid: 0a034f50-3060-4114-98e6-b5085326da0d ``` -------------------------------- ### Import necessary packages for storage conversion Source: https://github.com/azure/azure-service-operator/blob/main/docs/hugo/content/contributing/upgrade-resource-version/_index.md Imports the required storage packages for versioned resources and the genruntime package for resource references. This is a standard setup for implementing conversion logic. ```go // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. package storage import ( v20231115s "github.com/Azure/azure-service-operator/v2/api/documentdb/v1api20231115/storage" "github.com/Azure/azure-service-operator/v2/pkg/genruntime" ) ```