Categorygithub.com/ericogr/azenv
modulepackage
0.0.4
Repository: https://github.com/ericogr/azenv.git
Documentation: pkg.go.dev

# README

Azure DevOps Environment Creation

Use this tool to set up an Azure DevOps Environment. An Environment is a collection of resources that can be targeted by deployments from a pipeline.

Requirements

To run this tool, you need:

  • Azure DevOps account
  • Azure DevOps PAT with the following permissions:
    • Environment (Read & manage)
    • Service Connections (Read, query, & manage)
  • For Kubernetes resources:
    • Kubernetes Cluster
    • RBAC access with the following permissions:
      • get, create and patch namespaces
      • get and create serviceaccounts
      • get and create secrets

Kubernetes Resources

For Kubernetes resources these are the resources that can be configured:

ResourceTypeCan use existentNotes
EnvironmentAzure DevOpsYes-
Environment ResourceAzure DevOpsNoit must be deleted before creating a new one
Service ConnectionAzure DevOpsYes-
NamespaceKubernetesYes-
Service AccountKubernetesYesyou have to create role/clusterrole and bind to service account your own
SecretKubernetesYes-

NOTE: In some cases, cli will try to use existent resource before create a new one.

Kubernetes detailed permissions

To create and get some resources, cli will need some permissions. See an example of ClusterRole below:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: azenv
rules:
- apiGroups:
  - ""
  resources:
  - namespaces
  - serviceaccounts
  - secret
  verbs:
  - get
  - create
- apiGroups:
  - ""
  resources:
  - namespaces
  verbs:
  - patch

Usage example

See above an example, the fields are self-explanatory. Replace by your own values.

./azenv \
  create kubernetes \
  --pat <generate-azure-devops-pat> \
  --project <organization-name>/<project-name> \
  --name <environment-name> \
  --service-account <namespace>/<service-account-name> \
  --service-connection <service-connection-name> \
  --namespace-label label1=value1 \
  --namespace-label label2=value2 \
  --show-kubeconfig=false

# Packages

Copyright © 2022 NAME HERE <EMAIL ADDRESS> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
No description provided by the author