mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Adds an example of using Kubernetes to build a distributed task queue using Celery along with a RabbitMQ broker and Flower frontend. Resolves: #1788
		
			
				
	
	
		
			14 lines
		
	
	
		
			297 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			14 lines
		
	
	
		
			297 B
		
	
	
	
		
			Python
		
	
	
	
	
	
import os
 | 
						|
 | 
						|
from celery import Celery
 | 
						|
 | 
						|
# Get Kubernetes-provided address of the broker service
 | 
						|
broker_service_host = os.environ.get('RABBITMQ_SERVICE_SERVICE_HOST')
 | 
						|
 | 
						|
app = Celery('tasks', broker='amqp://guest@%s//' % broker_service_host, backend='amqp')
 | 
						|
 | 
						|
@app.task
 | 
						|
def add(x, y):
 | 
						|
    return x + y
 | 
						|
 |