mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Update redis example to use alpine:3.4
This commit is contained in:
		@@ -133,6 +133,9 @@ Now let's take a close look at what happens after this pod is deleted.  There ar
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
At this point we now have a reliable, scalable Redis installation.  By scaling the replication controller for redis servers, we can increase or decrease the number of read-slaves in our cluster.  Likewise, if failures occur, the redis-sentinels will perform master election and select a new master.
 | 
					At this point we now have a reliable, scalable Redis installation.  By scaling the replication controller for redis servers, we can increase or decrease the number of read-slaves in our cluster.  Likewise, if failures occur, the redis-sentinels will perform master election and select a new master.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					**NOTE:** since redis 3.2 some security measures (bind to 127.0.0.1 and `--protected-mode`) are enabled by default. Please read about this in http://antirez.com/news/96
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### tl; dr
 | 
					### tl; dr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
For those of you who are impatient, here is the summary of commands we ran in this tutorial:
 | 
					For those of you who are impatient, here is the summary of commands we ran in this tutorial:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,13 +12,14 @@
 | 
				
			|||||||
# See the License for the specific language governing permissions and
 | 
					# See the License for the specific language governing permissions and
 | 
				
			||||||
# limitations under the License.
 | 
					# limitations under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FROM redis:2.8
 | 
					FROM alpine:3.4
 | 
				
			||||||
RUN apt-get update
 | 
					
 | 
				
			||||||
RUN apt-get install -yy -q python
 | 
					RUN apk add -U redis sed bash && rm -rf /var/cache/apk/*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
COPY redis-master.conf /redis-master/redis.conf
 | 
					COPY redis-master.conf /redis-master/redis.conf
 | 
				
			||||||
COPY redis-slave.conf /redis-slave/redis.conf
 | 
					COPY redis-slave.conf /redis-slave/redis.conf
 | 
				
			||||||
COPY run.sh /run.sh
 | 
					COPY run.sh /run.sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CMD [ "/run.sh" ]
 | 
					CMD [ "/run.sh" ]
 | 
				
			||||||
ENTRYPOINT [ "sh", "-c" ]
 | 
					
 | 
				
			||||||
 | 
					ENTRYPOINT [ "bash", "-c" ]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -61,7 +61,8 @@ tcp-backlog 511
 | 
				
			|||||||
# Examples:
 | 
					# Examples:
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# bind 192.168.1.100 10.0.0.1
 | 
					# bind 192.168.1.100 10.0.0.1
 | 
				
			||||||
# bind 127.0.0.1
 | 
					
 | 
				
			||||||
 | 
					bind 0.0.0.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Specify the path for the Unix socket that will be used to listen for
 | 
					# Specify the path for the Unix socket that will be used to listen for
 | 
				
			||||||
# incoming connections. There is no default, so Redis will not listen
 | 
					# incoming connections. There is no default, so Redis will not listen
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -61,7 +61,8 @@ tcp-backlog 511
 | 
				
			|||||||
# Examples:
 | 
					# Examples:
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# bind 192.168.1.100 10.0.0.1
 | 
					# bind 192.168.1.100 10.0.0.1
 | 
				
			||||||
# bind 127.0.0.1
 | 
					
 | 
				
			||||||
 | 
					bind 0.0.0.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Specify the path for the Unix socket that will be used to listen for
 | 
					# Specify the path for the Unix socket that will be used to listen for
 | 
				
			||||||
# incoming connections. There is no default, so Redis will not listen
 | 
					# incoming connections. There is no default, so Redis will not listen
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,7 +19,7 @@ function launchmaster() {
 | 
				
			|||||||
    echo "Redis master data doesn't exist, data won't be persistent!"
 | 
					    echo "Redis master data doesn't exist, data won't be persistent!"
 | 
				
			||||||
    mkdir /redis-master-data
 | 
					    mkdir /redis-master-data
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  redis-server /redis-master/redis.conf
 | 
					  redis-server /redis-master/redis.conf --protected-mode no
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function launchsentinel() {
 | 
					function launchsentinel() {
 | 
				
			||||||
@@ -45,8 +45,9 @@ function launchsentinel() {
 | 
				
			|||||||
  echo "sentinel down-after-milliseconds mymaster 60000" >> ${sentinel_conf}
 | 
					  echo "sentinel down-after-milliseconds mymaster 60000" >> ${sentinel_conf}
 | 
				
			||||||
  echo "sentinel failover-timeout mymaster 180000" >> ${sentinel_conf}
 | 
					  echo "sentinel failover-timeout mymaster 180000" >> ${sentinel_conf}
 | 
				
			||||||
  echo "sentinel parallel-syncs mymaster 1" >> ${sentinel_conf}
 | 
					  echo "sentinel parallel-syncs mymaster 1" >> ${sentinel_conf}
 | 
				
			||||||
 | 
					  echo "bind 0.0.0.0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  redis-sentinel ${sentinel_conf}
 | 
					  redis-sentinel ${sentinel_conf} --protected-mode no
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function launchslave() {
 | 
					function launchslave() {
 | 
				
			||||||
@@ -66,9 +67,9 @@ function launchslave() {
 | 
				
			|||||||
    echo "Connecting to master failed.  Waiting..."
 | 
					    echo "Connecting to master failed.  Waiting..."
 | 
				
			||||||
    sleep 10
 | 
					    sleep 10
 | 
				
			||||||
  done
 | 
					  done
 | 
				
			||||||
  perl -pi -e "s/%master-ip%/${master}/" /redis-slave/redis.conf
 | 
					  sed -i "s/%master-ip%/${master}/" /redis-slave/redis.conf
 | 
				
			||||||
  perl -pi -e "s/%master-port%/6379/" /redis-slave/redis.conf
 | 
					  sed -i "s/%master-port%/6379/" /redis-slave/redis.conf
 | 
				
			||||||
  redis-server /redis-slave/redis.conf
 | 
					  redis-server /redis-slave/redis.conf --protected-mode no
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [[ "${MASTER}" == "true" ]]; then
 | 
					if [[ "${MASTER}" == "true" ]]; then
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,7 @@ spec:
 | 
				
			|||||||
    spec:
 | 
					    spec:
 | 
				
			||||||
      containers:
 | 
					      containers:
 | 
				
			||||||
      - name: redis
 | 
					      - name: redis
 | 
				
			||||||
        image: kubernetes/redis:v1
 | 
					        image: kubernetes/redis:v2
 | 
				
			||||||
        ports:
 | 
					        ports:
 | 
				
			||||||
        - containerPort: 6379
 | 
					        - containerPort: 6379
 | 
				
			||||||
        resources:
 | 
					        resources:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ metadata:
 | 
				
			|||||||
spec:
 | 
					spec:
 | 
				
			||||||
  containers:
 | 
					  containers:
 | 
				
			||||||
    - name: master
 | 
					    - name: master
 | 
				
			||||||
      image: kubernetes/redis:v1
 | 
					      image: kubernetes/redis:v2
 | 
				
			||||||
      env:
 | 
					      env:
 | 
				
			||||||
        - name: MASTER
 | 
					        - name: MASTER
 | 
				
			||||||
          value: "true"
 | 
					          value: "true"
 | 
				
			||||||
@@ -22,7 +22,7 @@ spec:
 | 
				
			|||||||
        - mountPath: /redis-master-data
 | 
					        - mountPath: /redis-master-data
 | 
				
			||||||
          name: data
 | 
					          name: data
 | 
				
			||||||
    - name: sentinel
 | 
					    - name: sentinel
 | 
				
			||||||
      image: kubernetes/redis:v1
 | 
					      image: kubernetes/redis:v2
 | 
				
			||||||
      env:
 | 
					      env:
 | 
				
			||||||
        - name: SENTINEL
 | 
					        - name: SENTINEL
 | 
				
			||||||
          value: "true"
 | 
					          value: "true"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@ metadata:
 | 
				
			|||||||
spec:
 | 
					spec:
 | 
				
			||||||
  containers:
 | 
					  containers:
 | 
				
			||||||
  - name: proxy
 | 
					  - name: proxy
 | 
				
			||||||
    image: kubernetes/redis-proxy:v1
 | 
					    image: kubernetes/redis-proxy:v2
 | 
				
			||||||
    ports:
 | 
					    ports:
 | 
				
			||||||
    - containerPort: 6379
 | 
					    - containerPort: 6379
 | 
				
			||||||
      name: api
 | 
					      name: api
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ spec:
 | 
				
			|||||||
    spec:
 | 
					    spec:
 | 
				
			||||||
      containers:
 | 
					      containers:
 | 
				
			||||||
      - name: sentinel
 | 
					      - name: sentinel
 | 
				
			||||||
        image: kubernetes/redis:v1
 | 
					        image: kubernetes/redis:v2
 | 
				
			||||||
        env:
 | 
					        env:
 | 
				
			||||||
          - name: SENTINEL
 | 
					          - name: SENTINEL
 | 
				
			||||||
            value: "true"
 | 
					            value: "true"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user