apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: app-prod
labels:
pod: app
track: production
annotations:
scheduler.alpha.kubernetes.io/affinity: >
{
"nodeAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [
{
"matchExpressions": [
{
"key": "beta.kubernetes.io/instance-type",
"operator": "In",
"values": ["c4.large"]
}
]
}
]
}
}
}
spec:
replicas: 5
template:
metadata:
labels:
pod: app
track: production
spec:
containers:
- image: quay.io/user/api:develop
name: api
ports:
- containerPort: 3000
env:
- name: DATABASE
value: mongodb://mongo-db:27000//api-v2?replicaSet=mongo
imagePullPolicy: Always
- image: quay.io/user/media:develop
name: media
ports:
- containerPort: 4000
imagePullPolicy: Always
imagePullSecrets:
# we download these from quay.io account
- name: my-pull-secret
/* eslint-disable no-console */const fs = require('fs');const K8Api = require('kubernetes-client');
module.exports.handle = (event, context, cb) => { console.log('quay.io', JSON.stringify(event.body)); const clusterUrls = { }; const stage = event.stage; const deployment = event.query.deployment; const container = event.query.container; const k8 = new K8Api.Extensions({ url: clusterUrls[stage], version: 'v1beta1', ca: fs.readFileSync(`${stage}-ca.pem`), cert: fs.readFileSync(`${stage}-k8s-admin.pem`), key: fs.readFileSync(`${stage}-k8s-admin-key.pem`), }); k8.ns.deployment.get(deployment, (err, result) => { if (err) { cb(err); } else { const match = result.spec.template.spec.containers .filter(c => c.name === container); const currentImage = match && match[0].image; console.log('k8s.current', currentImage); const currentTag = currentImage.split(/:/)[1]; const tags = event.body.docker_tags; const tag = tags.filter(t => t !== currentTag)[0] || 'latest'; const dockerImage = `${event.body.docker_url}:${tag}`; const patch = { name: deployment, body: { spec: { template: { spec: { containers: [{ name: container, image: dockerImage, }], }, }, }, }, }; console.log('k8s.patch', stage, JSON.stringify(patch)); k8.ns.deployments.patch(patch, (err2, result2) => { console.log('k8s.result', JSON.stringify(result2 || null)); cb(err2, result2); }); } });};
then on quay.io i have a notification setup for Webhook POST, that executes on a successful build with an end point to the AWS lambda function, all works to a point, but for this inability to always pull the image
any advice is much appreciate on how to solve this and whether it is the right way to do it?
so my question, how do i force the kubectl to pull the latest image from a specific branch
--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/uh_ON-SrVoc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.
Rodrigo
--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/uh_ON-SrVoc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.