This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Random-Liu/add-initial-code
Add initial code
- Loading branch information
Showing
254 changed files
with
96,513 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/golang/glog" | ||
"github.com/spf13/pflag" | ||
|
||
"github.com/kubernetes-incubator/cri-containerd/cmd/cri-containerd/options" | ||
"github.com/kubernetes-incubator/cri-containerd/pkg/server" | ||
) | ||
|
||
func main() { | ||
o := options.NewCRIContainerdOptions() | ||
o.AddFlags(pflag.CommandLine) | ||
options.InitFlags() | ||
|
||
glog.V(2).Infof("Connect to containerd socket %q with timeout %v", o.ContainerdSocketPath, o.ContainerdConnectionTimeout) | ||
conn, err := server.ConnectToContainerd(o.ContainerdSocketPath, o.ContainerdConnectionTimeout) | ||
if err != nil { | ||
glog.Exitf("Failed to connect containerd socket %q: %v", o.ContainerdSocketPath, err) | ||
} | ||
|
||
glog.V(2).Infof("Run cri-containerd grpc server on socket %q", o.CRIContainerdSocketPath) | ||
service := server.NewCRIContainerdService(conn) | ||
s := server.NewCRIContainerdServer(o.CRIContainerdSocketPath, service, service) | ||
if err := s.Run(); err != nil { | ||
glog.Exitf("Failed to run cri-containerd grpc server: %v", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package options | ||
|
||
import ( | ||
"flag" | ||
"time" | ||
|
||
"github.com/spf13/pflag" | ||
) | ||
|
||
// CRIContainerdOptions contains cri-containerd command line options. | ||
type CRIContainerdOptions struct { | ||
// CRIContainerdSocketPath is the path to the socket which cri-containerd serves on. | ||
CRIContainerdSocketPath string | ||
// ContainerdSocketPath is the path to the containerd socket. | ||
ContainerdSocketPath string | ||
// ContainerdConnectionTimeout is the connection timeout for containerd client. | ||
ContainerdConnectionTimeout time.Duration | ||
} | ||
|
||
func NewCRIContainerdOptions() *CRIContainerdOptions { | ||
return &CRIContainerdOptions{} | ||
} | ||
|
||
// AddFlags adds cri-containerd command line options to pflag. | ||
func (c *CRIContainerdOptions) AddFlags(fs *pflag.FlagSet) { | ||
fs.StringVar(&c.CRIContainerdSocketPath, "cri-containerd-socket", | ||
"/var/run/cri-containerd.sock", "Path to the socket which cri-containerd serves on.") | ||
fs.StringVar(&c.ContainerdSocketPath, "containerd-socket", | ||
"/run/containerd/containerd.sock", "Path to the containerd socket.") | ||
fs.DurationVar(&c.ContainerdConnectionTimeout, "containerd-connection-timeout", | ||
2*time.Minute, "Connection timeout for containerd client.") | ||
} | ||
|
||
func InitFlags() { | ||
pflag.CommandLine.AddGoFlagSet(flag.CommandLine) | ||
pflag.Parse() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package server | ||
|
||
import ( | ||
"errors" | ||
|
||
"golang.org/x/net/context" | ||
|
||
"k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" | ||
) | ||
|
||
// Attach prepares a streaming endpoint to attach to a running container, and returns the address. | ||
func (c *criContainerdService) Attach(ctx context.Context, r *runtime.AttachRequest) (*runtime.AttachResponse, error) { | ||
return nil, errors.New("not implemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package server | ||
|
||
import ( | ||
"errors" | ||
|
||
"golang.org/x/net/context" | ||
|
||
"k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" | ||
) | ||
|
||
// CreateContainer creates a new container in the given PodSandbox. | ||
func (c *criContainerdService) CreateContainer(ctx context.Context, r *runtime.CreateContainerRequest) (*runtime.CreateContainerResponse, error) { | ||
return nil, errors.New("not implemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package server | ||
|
||
import ( | ||
"errors" | ||
|
||
"golang.org/x/net/context" | ||
|
||
"k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" | ||
) | ||
|
||
// Exec prepares a streaming endpoint to execute a command in the container, and returns the address. | ||
func (c *criContainerdService) Exec(ctx context.Context, r *runtime.ExecRequest) (*runtime.ExecResponse, error) { | ||
return nil, errors.New("not implemented") | ||
} |
Oops, something went wrong.