1+ #
2+ # Licensed to the Apache Software Foundation (ASF) under one
3+ # or more contributor license agreements. See the NOTICE file
4+ # distributed with this work for additional information
5+ # regarding copyright ownership. The ASF licenses this file
6+ # to you under the Apache License, Version 2.0 (the
7+ # "License"); you may not use this file except in compliance
8+ # with the License. You may obtain a copy of the License at
9+ #
10+ # https://www.apache.org/licenses/LICENSE-2.0
11+ #
12+ # Unless required by applicable law or agreed to in writing,
13+ # software distributed under the License is distributed on an
14+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+ # KIND, either express or implied. See the License for the
16+ # specific language governing permissions and limitations
17+ # under the License.
18+ #
19+
20+ # Variables
21+ REGISTRY ?= accumulo
22+ TAG ?= 4.0.0-SNAPSHOT
23+ RELEASE_NAME ?= accumulo-dev
24+ NAMESPACE ?= default
25+ VALUES_FILE ?= charts/accumulo/values-dev.yaml
26+
27+ # Colors
28+ BLUE = \033[0;34m
29+ GREEN = \033[0;32m
30+ YELLOW = \033[1;33m
31+ RED = \033[0;31m
32+ NC = \033[0m # No Color
33+
34+ # Helper function to print colored output
35+ define log_info
36+ @echo -e "$(BLUE ) [INFO]$(NC ) $(1 ) "
37+ endef
38+
39+ define log_success
40+ @echo -e "$(GREEN ) [SUCCESS]$(NC ) $(1 ) "
41+ endef
42+
43+ define log_warning
44+ @echo -e "$(YELLOW ) [WARNING]$(NC ) $(1 ) "
45+ endef
46+
47+ define log_error
48+ @echo -e "$(RED ) [ERROR]$(NC ) $(1 ) "
49+ endef
50+
51+ .PHONY : help
52+ help : # # Show this help message
53+ @echo " Apache Accumulo with Alluxio on Kubernetes"
54+ @echo " "
55+ @echo " Available targets:"
56+ @awk ' BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST )
57+ @echo " "
58+ @echo " Variables:"
59+ @echo " REGISTRY=$( REGISTRY) - Docker registry"
60+ @echo " TAG=$( TAG) - Docker tag"
61+ @echo " RELEASE_NAME=$( RELEASE_NAME) - Helm release name"
62+ @echo " NAMESPACE=$( NAMESPACE) - Kubernetes namespace"
63+ @echo " VALUES_FILE=$( VALUES_FILE) - Helm values file"
64+
65+ .PHONY : build
66+ build : # # Build Accumulo distribution
67+ $(call log_info,"Building Accumulo distribution...")
68+ mvn clean package -DskipTests -pl assemble -am
69+ $(call log_success,"Accumulo distribution built successfully")
70+
71+ .PHONY : docker-build
72+ docker-build : build # # Build Docker image
73+ $(call log_info,"Building Docker image: $(REGISTRY ) /accumulo:$(TAG ) ")
74+ ./scripts/build-docker.sh -r $(REGISTRY ) -t $(TAG )
75+ $(call log_success,"Docker image built successfully")
76+
77+ .PHONY : docker-push
78+ docker-push : build # # Build and push Docker image
79+ $(call log_info,"Building and pushing Docker image: $(REGISTRY ) /accumulo:$(TAG ) ")
80+ ./scripts/build-docker.sh -r $(REGISTRY ) -t $(TAG ) -p
81+ $(call log_success,"Docker image built and pushed successfully")
82+
83+ .PHONY : generate-config
84+ generate-config : # # Generate configuration with secrets
85+ $(call log_info,"Generating configuration...")
86+ ./scripts/generate-secrets.sh -o values-generated.yaml --non-interactive -i $(RELEASE_NAME )
87+ $(call log_success,"Configuration generated: values-generated.yaml")
88+
89+ .PHONY : generate-config-interactive
90+ generate-config-interactive : # # Generate configuration interactively
91+ $(call log_info,"Generating configuration interactively...")
92+ ./scripts/generate-secrets.sh -o values-generated.yaml -i $(RELEASE_NAME )
93+ $(call log_success,"Configuration generated: values-generated.yaml")
94+
95+ .PHONY : deploy-dev
96+ deploy-dev : # # Deploy development environment
97+ $(call log_info,"Deploying development environment...")
98+ ./scripts/helm-deploy.sh install -r $(RELEASE_NAME ) -f $(VALUES_FILE ) --create-namespace -n $(NAMESPACE )
99+ $(call log_success,"Development environment deployed successfully")
100+
101+ .PHONY : deploy
102+ deploy : generate-config # # Deploy with generated configuration
103+ $(call log_info,"Deploying with generated configuration...")
104+ ./scripts/helm-deploy.sh install -r $(RELEASE_NAME ) -f values-generated.yaml --create-namespace -n $(NAMESPACE )
105+ $(call log_success,"Deployment completed successfully")
106+
107+ .PHONY : upgrade
108+ upgrade : # # Upgrade existing deployment
109+ $(call log_info,"Upgrading deployment...")
110+ ./scripts/helm-deploy.sh upgrade -r $(RELEASE_NAME ) -f $(VALUES_FILE ) -n $(NAMESPACE )
111+ $(call log_success,"Upgrade completed successfully")
112+
113+ .PHONY : test
114+ test : # # Run smoke tests
115+ $(call log_info,"Running smoke tests...")
116+ ./scripts/helm-deploy.sh test -r $(RELEASE_NAME ) -n $(NAMESPACE )
117+ $(call log_success,"Tests completed successfully")
118+
119+ .PHONY : status
120+ status : # # Show deployment status
121+ ./scripts/helm-deploy.sh status -r $(RELEASE_NAME ) -n $(NAMESPACE )
122+
123+ .PHONY : uninstall
124+ uninstall : # # Uninstall deployment
125+ $(call log_warning,"Uninstalling deployment...")
126+ ./scripts/helm-deploy.sh uninstall -r $(RELEASE_NAME ) -n $(NAMESPACE )
127+ $(call log_success,"Deployment uninstalled successfully")
128+
129+ .PHONY : logs
130+ logs : # # Show logs from all Accumulo components
131+ $(call log_info,"Showing logs from Accumulo components...")
132+ kubectl logs -l app.kubernetes.io/name=accumulo -n $(NAMESPACE ) --tail=100
133+
134+ .PHONY : shell
135+ shell : # # Access Accumulo shell
136+ $(call log_info,"Connecting to Accumulo shell...")
137+ kubectl exec -it deployment/$(RELEASE_NAME ) -manager -n $(NAMESPACE ) -- /opt/accumulo/bin/accumulo shell -u root
138+
139+ .PHONY : port-forward
140+ port-forward : # # Forward ports for local access
141+ $(call log_info,"Setting up port forwarding...")
142+ @echo " Accumulo Monitor will be available at: http://localhost:9995"
143+ @echo " Alluxio Master will be available at: http://localhost:19999"
144+ @echo " Press Ctrl+C to stop port forwarding"
145+ kubectl port-forward svc/$(RELEASE_NAME ) -monitor 9995:9995 -n $(NAMESPACE ) &
146+ kubectl port-forward svc/$(RELEASE_NAME ) -alluxio-master 19999:19999 -n $(NAMESPACE ) &
147+ wait
148+
149+ .PHONY : clean-docker
150+ clean-docker : # # Clean up Docker images and containers
151+ $(call log_info,"Cleaning up Docker images...")
152+ docker images | grep $(REGISTRY ) /accumulo | awk ' {print $$3}' | xargs -r docker rmi -f
153+ $(call log_success,"Docker cleanup completed")
154+
155+ .PHONY : validate
156+ validate : # # Validate Helm chart
157+ $(call log_info,"Validating Helm chart...")
158+ helm lint charts/accumulo
159+ $(call log_success,"Helm chart validation passed")
160+
161+ .PHONY : template
162+ template : # # Generate Kubernetes templates
163+ $(call log_info,"Generating Kubernetes templates...")
164+ helm template $(RELEASE_NAME ) charts/accumulo -f $(VALUES_FILE ) --namespace $(NAMESPACE ) > accumulo-templates.yaml
165+ $(call log_success,"Templates generated: accumulo-templates.yaml")
166+
167+ .PHONY : debug
168+ debug : # # Debug deployment issues
169+ $(call log_info,"Gathering debug information...")
170+ @echo " === Helm Status ==="
171+ -helm status $(RELEASE_NAME ) -n $(NAMESPACE )
172+ @echo " "
173+ @echo " === Pod Status ==="
174+ -kubectl get pods -l app.kubernetes.io/name=accumulo -n $(NAMESPACE )
175+ @echo " "
176+ @echo " === Service Status ==="
177+ -kubectl get services -l app.kubernetes.io/name=accumulo -n $(NAMESPACE )
178+ @echo " "
179+ @echo " === Recent Events ==="
180+ -kubectl get events -n $(NAMESPACE ) --sort-by=' .lastTimestamp' | tail -10
181+ @echo " "
182+ @echo " === Pod Descriptions ==="
183+ -kubectl describe pods -l app.kubernetes.io/name=accumulo -n $(NAMESPACE )
184+
185+ .PHONY : kind-create
186+ kind-create : # # Create KinD cluster for local development
187+ $(call log_info,"Creating KinD cluster...")
188+ kind create cluster --name accumulo-dev --config - << EOF
189+ kind: Cluster
190+ apiVersion: kind.x-k8s.io/v1alpha4
191+ nodes:
192+ - role: control-plane
193+ extraPortMappings:
194+ - containerPort: 80
195+ hostPort: 80
196+ protocol: TCP
197+ - containerPort: 443
198+ hostPort: 443
199+ protocol: TCP
200+ - containerPort: 9995
201+ hostPort: 9995
202+ protocol: TCP
203+ EOF
204+ $(call log_success,"KinD cluster created successfully")
205+
206+ .PHONY : kind-delete
207+ kind-delete : # # Delete KinD cluster
208+ $(call log_info,"Deleting KinD cluster...")
209+ kind delete cluster --name accumulo-dev
210+ $(call log_success,"KinD cluster deleted successfully")
211+
212+ .PHONY : full-dev-setup
213+ full-dev-setup : kind-create deploy-dev test # # Complete development setup
214+ $(call log_success,"Full development setup completed!")
215+ @echo " "
216+ @echo " Access services:"
217+ @echo " Accumulo Monitor: http://localhost:9995 (after running 'make port-forward')"
218+ @echo " Accumulo Shell: make shell"
219+ @echo " "
220+ @echo " Useful commands:"
221+ @echo " make logs - View logs"
222+ @echo " make status - Check status"
223+ @echo " make test - Run tests"
224+
225+ .PHONY : full-cleanup
226+ full-cleanup : uninstall kind-delete clean-docker # # Complete cleanup
227+ $(call log_success,"Full cleanup completed!")
228+
229+ # Default target
230+ .DEFAULT_GOAL := help
0 commit comments