Overview
In a traditional AWX installation, jobs (ansible-playbook runs) are executed directly on cluster members. Container Groups introduce an ephemeral execution model that ensures a clean environment for every job run.Execution Models
Ephemeral
Pods created on-demand, exist only during job execution
Always-On
Manually created instances that persist beyond individual jobs
Configuration
AContainerGroup is an InstanceGroup that has an associated Credential for connecting to an OpenShift or Kubernetes cluster.
Prerequisites
Create Container Credential
ACredential must be created where the associated CredentialType is one of:
OpenShift User/Pass
openshift_username_passwordOpenShift Token
openshift_tokenKubernetes Bearer Token
kubernetes_bearer_tokenCreate a Container Group
Once aCredential has been associated with an InstanceGroup, the InstanceGroup.kubernetes property will return True.
Via API:
Once created, you can associate the Container Group with Job Templates, Inventories, or Organizations just like regular Instance Groups.
Pod Customization
Default Pod Spec
AWX provides a simple default pod specification in code. This includes:- Container image (execution environment)
- Resource requests/limits
- Volume mounts
- Security context
Custom Pod Specifications
A custom YAML document may be provided which will be merged on top of the default pod spec. This allows you to customize:Container Image
Specify custom execution environment image
Namespace
Target specific Kubernetes namespace
Resources
Set CPU and memory limits
Node Selection
Use node selectors or affinity rules
Security Context
Configure pod security settings
Volumes
Mount additional volumes
Example: Custom Pod Spec Override
Using Custom Image:Advanced Configuration
Namespace Configuration
Specify the namespace where pods should be created:Ensure the credential has permissions to create pods in the specified namespace.
Resource Limits
Set appropriate resource requests and limits:- Requests: Minimum resources guaranteed to the pod
- Limits: Maximum resources the pod can consume
- Set requests lower than limits to allow bursting
- Consider your playbook requirements and cluster capacity
Image Pull Secrets
For private container registries:Security Context
Configure security settings:Node Selection and Affinity
Target specific nodes:Job Execution Flow
Always-On Instances
For persistent execution capacity, manually create instances through the AWX API or UI:Kubernetes API Reference
For a full list of customizable pod options, refer to the Kubernetes documentation: Pod v1 API ReferenceTroubleshooting
Pods Not Starting
Jobs Failing in Containers
Performance Issues
Optimize Container Group Performance:- Use local container image caches
- Set appropriate resource requests/limits
- Consider node affinity to reduce pod scheduling time
- Use persistent volumes for shared data
Best Practices
Resource Planning
Size resource requests based on typical playbook requirements
Image Optimization
Use optimized execution environment images to reduce startup time
Namespace Isolation
Use separate namespaces for different teams or environments
Monitor Capacity
Watch cluster capacity and scale nodes as needed
Benefits of Container Groups
- Isolation: Each job runs in a fresh, clean environment
- Scalability: Dynamically scale job capacity with cluster resources
- Flexibility: Use different execution environments per job
- Resource Efficiency: Only consume resources during job execution
- Security: Leverage Kubernetes security features and isolation