-
Notifications
You must be signed in to change notification settings - Fork 144
[WIP] Add new README file for Console Operator #1006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
8b7c9a5
adcd62a
85458d7
01fecd6
02c6c29
48d37e5
3cb95ec
9d8e245
fd0743b
a30e32b
a888b1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo "🚀 Console Operator Custom Deployment Script" | ||
echo "=============================================" | ||
|
||
# Check if we're connected to a cluster | ||
if ! oc whoami >/dev/null 2>&1; then | ||
echo "❌ Error: Not connected to OpenShift cluster. Please run 'oc login' first." | ||
exit 1 | ||
fi | ||
|
||
echo "✅ Connected to OpenShift cluster as: $(oc whoami)" | ||
|
||
# Check if the user has built and pushed their custom operator image | ||
echo "🔍 Custom Image Verification" | ||
echo "============================" | ||
|
||
# Extract image names from the YAML file | ||
OPERATOR_IMAGE=$(grep -E '^\s*image:\s*quay\.io' examples/07-operator-alt-image.yaml | head -1 | sed 's/.*image:\s*//') | ||
CONSOLE_IMAGE=$(grep -E '^\s*value:\s*quay\.io' examples/07-operator-alt-image.yaml | head -1 | sed 's/.*value:\s*//') | ||
|
||
echo "📋 Detected images from examples/07-operator-alt-image.yaml:" | ||
echo " Operator Image: $OPERATOR_IMAGE" | ||
echo " Console Image: $CONSOLE_IMAGE" | ||
echo "" | ||
|
||
echo "Before proceeding, please confirm:" | ||
echo "1. You have built your custom operator image" | ||
echo "2. You have pushed it to your registry (any registry, not just Docker Hub)" | ||
echo "3. The image path you provided is accessible" | ||
echo "4. You have updated the image path in examples/07-operator-alt-image.yaml" | ||
echo "5. You have updated the console image path in examples/07-operator-alt-image.yaml if you needed?" | ||
echo "" | ||
read -p "Have you done all the above? (y/N): " CONFIRM_BUILD | ||
|
||
|
||
if [[ ! "$CONFIRM_BUILD" =~ ^[Yy]$ ]]; then | ||
echo "❌ Please build and push your custom operator image first:" | ||
echo " docker build -t $CUSTOM_IMAGE_PATH ." | ||
echo " docker push $CUSTOM_IMAGE_PATH" | ||
echo " and update the image path in examples/07-operator-alt-image.yaml" | ||
echo " Then run this script again." | ||
exit 1 | ||
fi | ||
|
||
|
||
|
||
# Get cluster ID dynamically | ||
echo "📋 Getting cluster ID..." | ||
CLUSTER_ID=$(oc get clusterversion version -o jsonpath='{.spec.clusterID}') | ||
if [ -z "$CLUSTER_ID" ]; then | ||
echo "❌ Error: Could not retrieve cluster ID" | ||
exit 1 | ||
fi | ||
echo "✅ Cluster ID: $CLUSTER_ID" | ||
|
||
# Create temporary CVO unmanage configuration | ||
echo "📝 Creating CVO unmanage configuration..." | ||
TEMP_CVO_CONFIG=$(mktemp) | ||
cat > "$TEMP_CVO_CONFIG" << EOF | ||
apiVersion: config.openshift.io/v1 | ||
kind: ClusterVersion | ||
metadata: | ||
name: version | ||
spec: | ||
clusterID: $CLUSTER_ID | ||
overrides: | ||
- kind: Deployment | ||
name: console-operator | ||
namespace: openshift-console-operator | ||
unmanaged: true | ||
group: apps | ||
- kind: ClusterRole | ||
name: console-operator | ||
namespace: "" | ||
unmanaged: true | ||
group: rbac.authorization.k8s.io | ||
EOF | ||
|
||
# Step 1: Disable CVO management of console operator | ||
echo "" | ||
echo "📋 Step 1: Disabling CVO management of console operator..." | ||
oc apply -f "$TEMP_CVO_CONFIG" | ||
echo "✅ CVO management disabled" | ||
|
||
|
||
# Clean up temporary file | ||
rm "$TEMP_CVO_CONFIG" | ||
|
||
# Step 2: Scale down the default console operator | ||
echo "" | ||
echo "📋 Step 2: Scaling down default console operator..." | ||
oc scale --replicas 0 deployment console-operator --namespace openshift-console-operator | ||
echo "✅ Default console operator scaled down" | ||
|
||
# Step 3: Deploy the custom operator | ||
echo "" | ||
echo "📋 Step 3: Deploying custom console operator..." | ||
oc apply -f examples/07-operator-alt-image.yaml | ||
echo "✅ Custom console operator deployed" | ||
|
||
# Step 4: Wait for the operator to be ready | ||
echo "" | ||
echo "📋 Step 4: Waiting for operator to be ready..." | ||
echo "⏳ This may take a few minutes..." | ||
|
||
# Wait for deployment to be available | ||
oc rollout status deployment/console-operator -n openshift-console-operator --timeout=300s | ||
|
||
# Wait for pod to be ready | ||
echo "⏳ Waiting for pod to be ready..." | ||
oc wait --for=condition=ready pod -l name=console-operator -n openshift-console-operator --timeout=300s | ||
|
||
echo "✅ Operator is ready!" | ||
|
||
# Step 5: Show status | ||
echo "" | ||
echo "📋 Step 5: Checking operator status..." | ||
echo "" | ||
echo "🔍 Pod status:" | ||
oc get pods -n openshift-console-operator -l name=console-operator | ||
|
||
echo "" | ||
echo "🔍 Operator logs (last 10 lines):" | ||
oc logs -n openshift-console-operator -l name=console-operator --tail=10 | ||
|
||
echo "" | ||
echo "🔍 ClusterOperator status:" | ||
oc describe clusteroperator console | ||
|
||
echo "" | ||
echo "🎉 Deployment complete!" | ||
echo "" | ||
echo "📝 Next steps:" | ||
echo " - Monitor logs: oc logs -f -n openshift-console-operator -l name=console-operator" | ||
echo " - Check operator status: oc describe clusteroperator console" | ||
echo " - To update your operator:" | ||
echo " 1. Make code changes" | ||
echo " 2. Rebuild: make" | ||
echo " 3. Rebuild amd64 binary: GOOS=linux GOARCH=amd64 go build -mod=vendor -trimpath -ldflags '...' -o console-amd64 github.com/openshift/console-operator/cmd/console" | ||
echo " 4. Rebuild image: docker build --platform linux/amd64 -f Dockerfile.local -t quay.io/rh-ee-leoli/console-operator:latest ." | ||
echo " 5. Push image: docker push quay.io/rh-ee-leoli/console-operator:latest" | ||
echo " 6. Restart pod: oc delete pod -n openshift-console-operator -l name=console-operator" | ||
echo "" | ||
echo "🔄 To revert to default operator:" | ||
echo " - oc apply -f examples/cvo-manage-operator.yaml" | ||
echo " - oc scale --replicas 1 deployment console-operator --namespace openshift-console-operator" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# Console Operator | ||
|
||
The OpenShift Console Operator is a Kubernetes operator that manages the OpenShift web console deployment. It handles the installation, configuration, and lifecycle management of the OpenShift Console and its associated components. | ||
|
||
## Overview | ||
|
||
The Console Operator is responsible for: | ||
- Deploying and managing the OpenShift web console | ||
- Managing console downloads deployment | ||
- Configuring console authentication and authorization | ||
- Handling console customization (logos, branding, etc.) | ||
- Managing console routes and services | ||
- Ensuring console availability and health | ||
|
||
## Quick Start | ||
|
||
### Prerequisites | ||
|
||
- Go 1.23.0 or later | ||
- Docker | ||
- OpenShift CLI (`oc`) | ||
- Access to an OpenShift cluster | ||
|
||
|
||
### Building the Operator | ||
|
||
```bash | ||
# Clone the repository | ||
git clone https://github.com/openshift/console-operator.git | ||
cd console-operator | ||
|
||
# Build the operator binary | ||
make | ||
|
||
# Build for specific platform (e.g., Linux AMD64) | ||
GOOS=linux GOARCH=amd64 make | ||
``` | ||
|
||
### Running Tests | ||
|
||
```bash | ||
# Run unit tests | ||
make test-unit | ||
|
||
# Run end-to-end tests | ||
# It is suggested to run `integration` and `e2e` tests with CI. This is automatic when opening a PR. | ||
make test-e2e | ||
|
||
# Run all tests | ||
make test | ||
|
||
# Verify code formatting and linting | ||
make verify | ||
``` | ||
|
||
## Development | ||
|
||
### Local Development Setup | ||
|
||
For detailed development instructions, see [DEVELOPMENT.md](DEVELOPMENT.md). | ||
|
||
#### Quick Development Workflow | ||
|
||
1. **Build and deploy to a development cluster**: | ||
```bash | ||
# Build Docker image | ||
# Note: Ensure the image architecture matches your target platform | ||
# For multi-arch builds, use: docker buildx build --platform linux/amd64,linux/arm64 | ||
docker build -f Dockerfile.rhel7 -t quay.io/your-username/console-operator:latest . | ||
|
||
|
||
# Push to registry | ||
docker push quay.io/your-username/console-operator:latest | ||
|
||
``` | ||
|
||
2. **Update image paths in the deployment configuration**: | ||
```bash | ||
# Edit the deployment file to use your custom images | ||
# Update both the operator image and console image paths | ||
vim examples/07-operator-alt-image.yaml | ||
``` | ||
|
||
**Important**: Before running the deployment script, you must update the following in `examples/07-operator-alt-image.yaml`: | ||
|
||
- **Operator Image**: Change `quay.io/<your username>/console-operator:latest` to your custom operator image path | ||
- **Console Image**: Change `quay.io/<your username>/console:latest` to your custom console image path (if you have one) | ||
|
||
Example configuration: | ||
```yaml | ||
# In examples/07-operator-alt-image.yaml | ||
containers: | ||
- name: console-operator | ||
image: quay.io/your-username/console-operator:latest # ← Update this | ||
# ... other config ... | ||
env: | ||
- name: CONSOLE_IMAGE | ||
value: quay.io/your-username/console:latest # ← Update this if needed | ||
``` | ||
|
||
3. **Deploy using the custom operator script**: | ||
```bash | ||
# Make the script executable | ||
chmod +x deploy-custom-operator.sh | ||
|
||
# Run the deployment script | ||
./deploy-custom-operator.sh | ||
``` | ||
|
||
|
||
The script will: | ||
- Verify your custom images are accessible | ||
- Disable CVO management of the console operator | ||
- Scale down the default operator | ||
- Deploy your custom operator | ||
- Wait for the deployment to be ready | ||
- Show deployment status and logs | ||
|
||
**⚠️ Important Notes**: | ||
- Ensure your custom images are built and pushed to a registry before running the script | ||
- The script will prompt for confirmation that you've updated the image paths | ||
- Make sure you have cluster admin permissions to modify operator deployments | ||
- The deployment may take several minutes to complete | ||
|
||
**Troubleshooting**: | ||
- If the deployment fails, check the operator logs: `oc logs -n openshift-console-operator -l name=console-operator` | ||
- To revert to the default operator: `oc apply -f examples/cvo-manage-operator.yaml` | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove all the emojis, they are out of place here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree, as this is not upstream project and it should be more professional.