Skip to content

Instantly share code, notes, and snippets.

@mattfysh
Last active December 17, 2023 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattfysh/aeabb6f295e6e532985cc8394bc46f5b to your computer and use it in GitHub Desktop.
Save mattfysh/aeabb6f295e6e532985cc8394bc46f5b to your computer and use it in GitHub Desktop.
Pulumi deploy k8s redpanda + console
import * as k8s from '@pulumi/kubernetes'
import dedent from 'dedent'
new k8s.apps.v1.Deployment('redpanda', {
metadata: {
labels: {
appClass: 'redpanda',
},
},
spec: {
replicas: 1,
selector: {
matchLabels: {
appClass: 'redpanda',
},
},
template: {
metadata: {
labels: {
appClass: 'redpanda',
},
},
spec: {
containers: [
{
name: 'redpanda',
image: 'redpandadata/redpanda',
args: [
'redpanda start',
'--smp 1',
'--overprovisioned',
'--kafka-addr internal://0.0.0.0:9092',
'--advertise-kafka-addr internal://redpanda:9092',
],
ports: [
{
containerPort: 9092,
},
],
},
],
},
},
},
})
const redpandaService = new k8s.core.v1.Service('redpanda-service', {
metadata: {
name: 'redpanda',
},
spec: {
type: 'ClusterIP', // the default if not specified
selector: {
appClass: 'redpanda',
},
ports: [{ port: 9092 }],
},
})
const consoleConfig = new k8s.core.v1.ConfigMap('console-config', {
data: {
config: dedent`
kafka:
brokers: ["redpanda:9092"]
`,
},
})
new k8s.apps.v1.Deployment('console', {
metadata: {
labels: {
appClass: 'console',
},
},
spec: {
replicas: 1,
selector: {
matchLabels: {
appClass: 'console',
},
},
template: {
metadata: {
labels: {
appClass: 'console',
},
},
spec: {
containers: [
{
name: 'console',
image: 'redpandadata/console',
volumeMounts: [
{
mountPath: '/tmp/config.yml',
name: 'config',
subPath: 'config',
},
],
env: [
{
name: 'CONFIG_FILEPATH',
value: '/tmp/config.yml',
},
],
ports: [{ containerPort: 8080 }],
},
],
volumes: [
{
name: 'config',
configMap: {
name: consoleConfig.metadata.name,
},
},
],
},
},
},
})
const consoleService = new k8s.core.v1.Service('console-service', {
metadata: {
name: 'console',
},
spec: {
type: 'LoadBalancer', // exposes service on host
selector: {
appClass: 'console',
},
ports: [{ port: 8080 }],
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment