Skip to content

Latest commit

 

History

History
47 lines (40 loc) · 1.12 KB

README.md

File metadata and controls

47 lines (40 loc) · 1.12 KB

This is a incomplete experimentation of creating a C++ binding of Kubernetes go client library.

Environment

Go C++ 14 protobuf

clone the code
git clone https://github.com/jianhuiz/k8s-client-cpp

Note: All blocks below must be executed from the root of the repository.

get the dependencies
cd ./go
go mod vendor
generate c++ protobuf code
protoc -I $PWD/go/vendor --cpp_out $PWD/cpp/ \
    $PWD/go/vendor/k8s.io/api/core/v1/generated.proto \
    $PWD/go/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto \
    $PWD/go/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto \
    $PWD/go/vendor/k8s.io/apimachinery/pkg/runtime/generated.proto \
    $PWD/go/vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.proto \
    $PWD/go/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.proto
build go library
cd ./go
go build -buildmode=c-archive -o go.a
build c++ sample
cd ./cpp
make

macOS users

Change the LDFLAGS to:

LD_FLAGS = ../go/go.a -lprotobuf -lpthread -framework CoreFoundation -framework Security