Skip to content

Instantly share code, notes, and snippets.

@mattfysh
Last active February 8, 2024 05:41
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/b79e9e295023a3d390ca2830773f378e to your computer and use it in GitHub Desktop.
Save mattfysh/b79e9e295023a3d390ca2830773f378e to your computer and use it in GitHub Desktop.
Pulumi Kubernetes - deployment preview error
import * as k8s from '@pulumi/kubernetes'
const provider = new k8s.Provider('k8s-provider', {
context: 'docker-desktop',
namespace: 'testns',
})
const ns = new k8s.core.v1.Namespace(
'ns',
{ metadata: { name: 'testns' } },
{ provider }
)
const service = new k8s.core.v1.Service(
'service',
{
metadata: {
annotations: { 'pulumi.com/skipAwait': 'true' },
},
spec: {
selector: { app: 'app1' },
ports: [{ port: 80 }],
},
},
{ provider, dependsOn: [ns] }
)
new k8s.apps.v1.Deployment(
'deployment',
{
metadata: { labels: { app: 'app2' } },
spec: {
replicas: 1,
strategy: { type: 'Recreate' },
selector: { matchLabels: { app: 'app2' } },
template: {
metadata: { labels: { app: 'app2' } },
spec: {
hostAliases: [
{
ip: service.spec.clusterIP,
hostnames: ['app1'],
},
],
containers: [{ name: 'nginx', image: 'nginx:latest' }],
},
},
},
},
{ provider, dependsOn: [ns] }
)
@mattfysh
Copy link
Author

mattfysh commented Feb 8, 2024

 kubernetes:apps/v1:Deployment (deployment):
    error:
Preview failed:
resource testns/deployment-c56d59ed was not successfully created by the Kubernetes API server :
failed to create typed patch object (testns/deployment-c56d59ed; apps/v1, Kind=Deployment):
.spec.template.spec.hostAliases:
element 0:
associative list with keys has an element that omits key field "ip" (and doesn't have default value)

This seems to be a race condition related to the namespace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment