Skip to content

Commit

Permalink
Merge pull request #734 from volume-ji/jiyuan
Browse files Browse the repository at this point in the history
support configurable stream-port to virtlet server instead of default 10010
  • Loading branch information
ivan4th authored Aug 24, 2018
2 parents 39b50b6 + 5d93aa1 commit 6ac1a65
Show file tree
Hide file tree
Showing 31 changed files with 67 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ standard Virtlet deployment YAML as generated by `virtletctl gen`.
| Calico subnet size to use | `calicoSubnetSize` | `24` | integer | `--calico-subnet-size` / `VIRTLET_CALICO_SUBNET` |
| Enable regexp image name translation | `enableRegexpImageTranslation` | `true` | boolean | `--enable-regexp-image-translation` / `IMAGE_REGEXP_TRANSLATION` |
| CPU model to use in libvirt domain definition (libvirt's default value will be used if not set) | `cpuModel` | | string | `--cpu-model` / `VIRTLET_CPU_MODEL` |
| configurable port to the virtlet server | `streamPort` | `10010` | integer | `--stream-port` / `VIRTLET_STREAM_PORT` |
| Log level to use | `logLevel` | `1` | integer | `--v` / `VIRTLET_LOGLEVEL` |
<!-- end -->

Expand Down
3 changes: 2 additions & 1 deletion docs/virtletctl/virtletctl_diag_sonobuoy.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ virtletctl diag sonobuoy [flags]
### Options

```
-h, --help help for sonobuoy
-h, --help help for sonobuoy
--tag string Set virtlet image tag for the plugin
```

### Options inherited from parent commands
Expand Down
2 changes: 1 addition & 1 deletion images/image_skel/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ verbose=
if [[ ${VIRTLET_LOGLEVEL:-} ]]; then
verbose="--v ${VIRTLET_LOGLEVEL}"
fi
/usr/local/bin/virtlet ${verbose}
/usr/local/bin/virtlet ${verbose} $*
2 changes: 2 additions & 0 deletions pkg/api/virtlet.k8s/v1/virtletconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ type VirtletConfig struct {
// CPUModel specifies the default CPU model to use in the libvirt domain definition.
// It can be overridden using VirtletCPUModel pod annotation.
CPUModel *string `json:"cpuModel,omitempty"`
// StreamPort specifies the configurable stream port of virtlet server.
StreamPort *int `json:"streamPort,omitempty"`
// LogLevel specifies the log level to use
LogLevel *int `json:"logLevel,omitempty"`
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/api/virtlet.k8s/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/config/TestConfigForNode__global_mapping.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ libvirtURI: qemu:///foobar
logLevel: 3
rawDevices: sd*
skipImageTranslation: false
streamPort: 10010
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ libvirtURI: qemu:///foobar
logLevel: 3
rawDevices: sd*
skipImageTranslation: false
streamPort: 10010
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ libvirtURI: qemu:///system
logLevel: 1
rawDevices: loop*
skipImageTranslation: false
streamPort: 10010
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ libvirtURI: qemu:///foobar
logLevel: 3
rawDevices: sd*
skipImageTranslation: false
streamPort: 10010
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ libvirtURI: qemu:///system
logLevel: 1
rawDevices: loop*
skipImageTranslation: false
streamPort: 10010
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ libvirtURI: qemu:///system
logLevel: 1
rawDevices: vd*
skipImageTranslation: false
streamPort: 10010
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ libvirtURI: qemu:///system
logLevel: 1
rawDevices: vd*
skipImageTranslation: false
streamPort: 10010
1 change: 1 addition & 0 deletions pkg/config/TestConfigForNode__no_mappings.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ libvirtURI: qemu:///system
logLevel: 1
rawDevices: loop*
skipImageTranslation: false
streamPort: 10010
1 change: 1 addition & 0 deletions pkg/config/TestDefaultVirtletConfig.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ libvirtURI: qemu:///system
logLevel: 1
rawDevices: loop*
skipImageTranslation: false
streamPort: 10010
1 change: 1 addition & 0 deletions pkg/config/TestGenerateDoc.out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
| Calico subnet size to use | `calicoSubnetSize` | `24` | integer | `--calico-subnet-size` / `VIRTLET_CALICO_SUBNET` |
| Enable regexp image name translation | `enableRegexpImageTranslation` | `true` | boolean | `--enable-regexp-image-translation` / `IMAGE_REGEXP_TRANSLATION` |
| CPU model to use in libvirt domain definition (libvirt's default value will be used if not set) | `cpuModel` | | string | `--cpu-model` / `VIRTLET_CPU_MODEL` |
| configurable port to the virtlet server | `streamPort` | `10010` | integer | `--stream-port` / `VIRTLET_STREAM_PORT` |
| Log level to use | `logLevel` | `1` | integer | `--v` / `VIRTLET_LOGLEVEL` |
4 changes: 4 additions & 0 deletions pkg/config/TestGetCRDDefinitions.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
type: string
skipImageTranslation:
type: boolean
streamPort:
maximum: 65535
minimum: 1
type: integer
nodeName:
type: string
nodeSelector:
Expand Down
1 change: 1 addition & 0 deletions pkg/config/TestLoadMappings.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ libvirtURI: qemu:///system
logLevel: 1
rawDevices: sd*
skipImageTranslation: false
streamPort: 10010
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ libvirtURI: qemu:///foobar
logLevel: 1
rawDevices: sd*
skipImageTranslation: false
streamPort: 10010
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export VIRTLET_CNI_CONFIG_DIR=/some/cni/conf/dir
export VIRTLET_CALICO_SUBNET=22
export IMAGE_REGEXP_TRANSLATION=''
export VIRTLET_CPU_MODEL=host-model
export VIRTLET_STREAM_PORT=10010
export VIRTLET_LOGLEVEL=1
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ libvirtURI: qemu:///system
logLevel: 1
rawDevices: loop*
skipImageTranslation: false
streamPort: 10010
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export VIRTLET_CNI_CONFIG_DIR=/etc/cni/net.d
export VIRTLET_CALICO_SUBNET=24
export IMAGE_REGEXP_TRANSLATION=1
export VIRTLET_CPU_MODEL=''
export VIRTLET_STREAM_PORT=10010
export VIRTLET_LOGLEVEL=1
4 changes: 4 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ const (

defaultCPUModel = ""
cpuModelEnv = "VIRTLET_CPU_MODEL"

defaultStreamPort = 10010
streamPortEnv = "VIRTLET_STREAM_PORT"
)

func configFieldSet(c *virtlet_v1.VirtletConfig) *fieldSet {
Expand All @@ -95,6 +98,7 @@ func configFieldSet(c *virtlet_v1.VirtletConfig) *fieldSet {
fs.addIntField("calicoSubnetSize", "calico-subnet-size", "", "Calico subnet size to use", calicoSubnetEnv, defaultCalicoSubnet, 0, 32, &c.CalicoSubnetSize)
fs.addBoolField("enableRegexpImageTranslation", "enable-regexp-image-translation", "", "Enable regexp image name translation", enableRegexpImageTranslationEnv, true, &c.EnableRegexpImageTranslation)
fs.addStringField("cpuModel", "cpu-model", "", "CPU model to use in libvirt domain definition (libvirt's default value will be used if not set)", cpuModelEnv, defaultCPUModel, &c.CPUModel)
fs.addIntField("streamPort", "stream-port", "", "configurable port to the virtlet server", streamPortEnv, defaultStreamPort, 1, 65535, &c.StreamPort)
// this field duplicates glog's --v, so no option for it, which is signified
// by "+" here (it's only for doc)
fs.addIntField("logLevel", "+v", "", "Log level to use", logLevelEnv, 1, 0, math.MaxInt32, &c.LogLevel)
Expand Down
2 changes: 1 addition & 1 deletion pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (v *VirtletManager) Run() error {

var streamServer StreamServer
if !*v.config.DisableLogging {
s, err := stream.NewServer(streamerSocketPath, v.metadataStore)
s, err := stream.NewServer(streamerSocketPath, v.metadataStore, *v.config.StreamPort)
if err != nil {
return fmt.Errorf("couldn't create stream server: %v", err)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/stream/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"net"
"os"
"strconv"
"syscall"

"github.com/Mirantis/virtlet/pkg/metadata"
Expand All @@ -46,7 +47,7 @@ type Server struct {
var _ streaming.Runtime = (*Server)(nil)

// NewServer creates a new Server
func NewServer(socketPath string, metadataStore metadata.Store) (*Server, error) {
func NewServer(socketPath string, metadataStore metadata.Store, iStreamPort int) (*Server, error) {
s := &Server{DeadlineSeconds: 10}

// Prepare unix server
Expand All @@ -56,7 +57,7 @@ func NewServer(socketPath string, metadataStore metadata.Store) (*Server, error)
if err != nil {
return nil, err
}
streamPort := "10010"
streamPort := strconv.Itoa(iStreamPort)

streamServerConfig := streaming.DefaultConfig
streamServerConfig.Addr = net.JoinHostPort(bindAddress.String(), streamPort)
Expand Down
4 changes: 4 additions & 0 deletions pkg/tools/TestGenCommand__compat.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@ spec:
type: string
skipImageTranslation:
type: boolean
streamPort:
maximum: 65535
minimum: 1
type: integer
nodeName:
type: string
nodeSelector:
Expand Down
4 changes: 4 additions & 0 deletions pkg/tools/TestGenCommand__compat_dev.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,10 @@ spec:
type: string
skipImageTranslation:
type: boolean
streamPort:
maximum: 65535
minimum: 1
type: integer
nodeName:
type: string
nodeSelector:
Expand Down
4 changes: 4 additions & 0 deletions pkg/tools/TestGenCommand__crd.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ spec:
type: string
skipImageTranslation:
type: boolean
streamPort:
maximum: 65535
minimum: 1
type: integer
nodeName:
type: string
nodeSelector:
Expand Down
4 changes: 4 additions & 0 deletions pkg/tools/TestGenCommand__dev.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,10 @@ spec:
type: string
skipImageTranslation:
type: boolean
streamPort:
maximum: 65535
minimum: 1
type: integer
nodeName:
type: string
nodeSelector:
Expand Down
4 changes: 4 additions & 0 deletions pkg/tools/TestGenCommand__plain.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,10 @@ spec:
type: string
skipImageTranslation:
type: boolean
streamPort:
maximum: 65535
minimum: 1
type: integer
nodeName:
type: string
nodeSelector:
Expand Down
4 changes: 4 additions & 0 deletions pkg/tools/TestGenCommand__tag.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,10 @@ spec:
type: string
skipImageTranslation:
type: boolean
streamPort:
maximum: 65535
minimum: 1
type: integer
nodeName:
type: string
nodeSelector:
Expand Down
1 change: 1 addition & 0 deletions pkg/tools/TestGenDocForConfig.out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
| Calico subnet size to use | `calicoSubnetSize` | `24` | integer | `--calico-subnet-size` / `VIRTLET_CALICO_SUBNET` |
| Enable regexp image name translation | `enableRegexpImageTranslation` | `true` | boolean | `--enable-regexp-image-translation` / `IMAGE_REGEXP_TRANSLATION` |
| CPU model to use in libvirt domain definition (libvirt's default value will be used if not set) | `cpuModel` | | string | `--cpu-model` / `VIRTLET_CPU_MODEL` |
| configurable port to the virtlet server | `streamPort` | `10010` | integer | `--stream-port` / `VIRTLET_STREAM_PORT` |
| Log level to use | `logLevel` | `1` | integer | `--v` / `VIRTLET_LOGLEVEL` |

0 comments on commit 6ac1a65

Please sign in to comment.