Fix: registry fails to start after node reboot
Currently registry Pod fails to start after node reboots with 'Pod Predicate MatchNodeSelector failed' error. This patch adds ReplicationController for the registry to ensure its availability. Change-Id: I7e5db3d907806fc3ea1f5e5fe1196d2ee7f9b915
This commit is contained in:
parent
a6664a573d
commit
d90a9cb2c8
|
@ -42,22 +42,16 @@ function kube_cmd {
|
|||
}
|
||||
|
||||
function await_readiness {
|
||||
pod_name=$1;
|
||||
get_pod="kube_cmd get pod $pod_name -o template --template "
|
||||
rc_name=$1;
|
||||
template="{{.status.readyReplicas}}/{{.spec.replicas}}"
|
||||
get_rc="kube_cmd get rc $rc_name -o template --template "
|
||||
|
||||
echo "Waiting for $pod_name pod readiness"
|
||||
echo "Waiting for $rc_name readiness"
|
||||
|
||||
template="{{.status.phase}}"
|
||||
while [ $($get_pod $template) != "Running" ]; do
|
||||
while $get_rc $template | egrep -v '^(.*)/\1$' > /dev/null; do
|
||||
sleep 3
|
||||
done
|
||||
echo "The $pod_name pod is running"
|
||||
|
||||
template="{{range.status.containerStatuses}}{{.ready}}{{end}}"
|
||||
while [ $($get_pod $template) != "true" ]; do
|
||||
sleep 3
|
||||
done
|
||||
echo "The $pod_name pod state is ready"
|
||||
echo "The $rc_name is ready"
|
||||
}
|
||||
|
||||
if [ -z $NODE ]; then
|
||||
|
@ -68,14 +62,14 @@ fi
|
|||
kubectl label node $NODE app=ccp-registry --overwrite
|
||||
|
||||
function deploy_registry {
|
||||
kube_cmd apply -f $WORKDIR/registry-pod.yaml
|
||||
kube_cmd apply -f $WORKDIR/registry-rc.yaml
|
||||
kube_cmd apply -f $WORKDIR/registry-service.yaml
|
||||
await_readiness registry
|
||||
kube_cmd get service registry
|
||||
}
|
||||
|
||||
function deploy_registry_ui {
|
||||
cat $WORKDIR/registry-ui-pod.yaml | envsubst | kube_cmd apply -f -
|
||||
cat $WORKDIR/registry-ui-rc.yaml | envsubst | kube_cmd apply -f -
|
||||
kube_cmd apply -f $WORKDIR/registry-ui-service.yaml
|
||||
await_readiness registry-ui
|
||||
kube_cmd get service registry-ui
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: registry
|
||||
labels:
|
||||
app: registry
|
||||
spec:
|
||||
containers:
|
||||
- name: registry
|
||||
image: registry:2
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
hostPort: 5000
|
||||
volumeMounts:
|
||||
- mountPath: /var/lib/registry
|
||||
name: registry-volume
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /v2/_catalog
|
||||
port: 5000
|
||||
initialDelaySeconds: 3
|
||||
timeoutSeconds: 1
|
||||
env:
|
||||
- name: REGISTRY_STORAGE_DELETE_ENABLED
|
||||
value: "true"
|
||||
nodeSelector:
|
||||
app: ccp-registry
|
||||
volumes:
|
||||
- name: registry-volume
|
||||
hostPath:
|
||||
path: /var/lib/ccp-registry
|
|
@ -0,0 +1,39 @@
|
|||
apiVersion: v1
|
||||
kind: ReplicationController
|
||||
metadata:
|
||||
name: registry
|
||||
labels:
|
||||
app: registry
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
name: registry
|
||||
labels:
|
||||
app: registry
|
||||
spec:
|
||||
containers:
|
||||
- name: registry
|
||||
image: registry:2
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
hostPort: 5000
|
||||
volumeMounts:
|
||||
- mountPath: /var/lib/registry
|
||||
name: registry-volume
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /v2/_catalog
|
||||
port: 5000
|
||||
initialDelaySeconds: 3
|
||||
timeoutSeconds: 1
|
||||
env:
|
||||
- name: REGISTRY_STORAGE_DELETE_ENABLED
|
||||
value: "true"
|
||||
nodeSelector:
|
||||
app: ccp-registry
|
||||
volumes:
|
||||
- name: registry-volume
|
||||
hostPath:
|
||||
path: /var/lib/ccp-registry
|
|
@ -1,30 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: registry-ui
|
||||
labels:
|
||||
app: registry-ui
|
||||
spec:
|
||||
containers:
|
||||
- name: registry-ui
|
||||
image: parabuzzle/docker-registry-ui:latest
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 80
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 80
|
||||
initialDelaySeconds: 3
|
||||
timeoutSeconds: 1
|
||||
env:
|
||||
- name: REGISTRY_ALLOW_DELETE
|
||||
value: "true"
|
||||
- name: REGISTRY_HOST
|
||||
value: "registry.${NAMESPACE}"
|
||||
- name: REGISTRY_PROTO
|
||||
value: "http"
|
||||
- name: REGISTRY_PORT
|
||||
value: "5000"
|
||||
nodeSelector:
|
||||
app: ccp-registry
|
|
@ -0,0 +1,37 @@
|
|||
apiVersion: v1
|
||||
kind: ReplicationController
|
||||
metadata:
|
||||
name: registry-ui
|
||||
labels:
|
||||
app: registry-ui
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
name: registry-ui
|
||||
labels:
|
||||
app: registry-ui
|
||||
spec:
|
||||
containers:
|
||||
- name: registry-ui
|
||||
image: parabuzzle/docker-registry-ui:latest
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 80
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 80
|
||||
initialDelaySeconds: 3
|
||||
timeoutSeconds: 1
|
||||
env:
|
||||
- name: REGISTRY_ALLOW_DELETE
|
||||
value: "true"
|
||||
- name: REGISTRY_HOST
|
||||
value: "registry.${NAMESPACE}"
|
||||
- name: REGISTRY_PROTO
|
||||
value: "http"
|
||||
- name: REGISTRY_PORT
|
||||
value: "5000"
|
||||
nodeSelector:
|
||||
app: ccp-registry
|
Loading…
Reference in New Issue