mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-13 21:25:09 +00:00
Allow replica set to be exposed as a service and add kubectl command tests for replica sets.
This commit is contained in:
@@ -39,12 +39,14 @@ Take a replication controller, service or pod and expose it as a new Kubernetes
|
||||
### Synopsis
|
||||
|
||||
|
||||
Take a replication controller, service, or pod and expose it as a new Kubernetes service.
|
||||
Take a replication controller, service, replica set or pod and expose it as a new Kubernetes service.
|
||||
|
||||
Looks up a replication controller, service, or pod by name and uses the selector for that resource as the
|
||||
selector for a new service on the specified port. Note that if no port is specified via --port and the
|
||||
exposed resource has multiple ports, all will be re-used by the new service. Also if no labels are specified,
|
||||
the new service will re-use the labels from the resource it exposes.
|
||||
Looks up a replication controller, service, replica set or pod by name and uses the selector for that
|
||||
resource as the selector for a new service on the specified port. A replica set will be exposed as a
|
||||
service only if it's selector is convertible to a selector that service supports, i.e. when the
|
||||
replica set selector contains only the matchLabels component. Note that if no port is specified
|
||||
via --port and the exposed resource has multiple ports, all will be re-used by the new service. Also
|
||||
if no labels are specified, the new service will re-use the labels from the resource it exposes.
|
||||
|
||||
```
|
||||
kubectl expose (-f FILENAME | TYPE NAME) [--port=port] [--protocol=TCP|UDP] [--target-port=number-or-name] [--name=name] [--external-ip=external-ip-of-service] [--type=type]
|
||||
@@ -67,6 +69,9 @@ $ kubectl expose service nginx --port=443 --target-port=8443 --name=nginx-https
|
||||
|
||||
# Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named 'video-stream'.
|
||||
$ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream
|
||||
|
||||
# Create a service for a replicated nginx using replica set, which serves on port 80 and connects to the containers on port 8000.
|
||||
$ kubectl expose rs nginx --port=80 --target-port=8000
|
||||
```
|
||||
|
||||
### Options
|
||||
@@ -88,7 +93,7 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream
|
||||
--protocol="TCP": The network protocol for the service to be created. Default is 'tcp'.
|
||||
--record[=false]: Record current kubectl command in the resource annotation.
|
||||
--save-config[=false]: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply on this object in the future.
|
||||
--selector="": A label selector to use for this service. If empty (the default) infer the selector from the replication controller.
|
||||
--selector="": A label selector to use for this service. Only equality-based selector requirements are supported. If empty (the default) infer the selector from the replication controller or replica set.
|
||||
--session-affinity="": If non-empty, set the session affinity for the service to this; legal values: 'None', 'ClientIP'
|
||||
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
|
||||
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column)
|
||||
@@ -130,7 +135,7 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream
|
||||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra on 22-Jan-2016
|
||||
###### Auto generated by spf13/cobra on 10-Feb-2016
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[]()
|
||||
|
42
docs/user-guide/replicaset/frontend.yaml
Normal file
42
docs/user-guide/replicaset/frontend.yaml
Normal file
@@ -0,0 +1,42 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: ReplicaSet
|
||||
metadata:
|
||||
name: frontend
|
||||
# these labels can be applied automatically
|
||||
# from the labels in the pod template if not set
|
||||
# labels:
|
||||
# app: guestbook
|
||||
# tier: frontend
|
||||
spec:
|
||||
# this replicas value is default
|
||||
# modify it according to your case
|
||||
replicas: 3
|
||||
# selector can be applied automatically
|
||||
# from the labels in the pod template if not set
|
||||
# selector:
|
||||
# matchLabels:
|
||||
# app: guestbook
|
||||
# tier: frontend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: guestbook
|
||||
tier: frontend
|
||||
spec:
|
||||
containers:
|
||||
- name: php-redis
|
||||
image: gcr.io/google_samples/gb-frontend:v3
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
env:
|
||||
- name: GET_HOSTS_FROM
|
||||
value: dns
|
||||
# If your cluster config does not include a dns service, then to
|
||||
# instead access environment variables to find service host
|
||||
# info, comment out the 'value: dns' line above, and uncomment the
|
||||
# line below.
|
||||
# value: env
|
||||
ports:
|
||||
- containerPort: 80
|
44
docs/user-guide/replicaset/redis-slave.yaml
Normal file
44
docs/user-guide/replicaset/redis-slave.yaml
Normal file
@@ -0,0 +1,44 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: ReplicaSet
|
||||
metadata:
|
||||
name: redis-slave
|
||||
# these labels can be applied automatically
|
||||
# from the labels in the pod template if not set
|
||||
# labels:
|
||||
# app: redis
|
||||
# role: slave
|
||||
# tier: backend
|
||||
spec:
|
||||
# this replicas value is default
|
||||
# modify it according to your case
|
||||
replicas: 2
|
||||
# selector can be applied automatically
|
||||
# from the labels in the pod template if not set
|
||||
# selector:
|
||||
# app: guestbook
|
||||
# role: slave
|
||||
# tier: backend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: redis
|
||||
role: slave
|
||||
tier: backend
|
||||
spec:
|
||||
containers:
|
||||
- name: slave
|
||||
image: gcr.io/google_samples/gb-redisslave:v1
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
env:
|
||||
- name: GET_HOSTS_FROM
|
||||
value: dns
|
||||
# If your cluster config does not include a dns service, then to
|
||||
# instead access an environment variable to find the master
|
||||
# service's host, comment out the 'value: dns' line above, and
|
||||
# uncomment the line below.
|
||||
# value: env
|
||||
ports:
|
||||
- containerPort: 6379
|
Reference in New Issue
Block a user