Skip to content

Commit

Permalink
change agent dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: yanjianbo <[email protected]>
  • Loading branch information
yanjianbo1983 committed Jan 8, 2024
1 parent 176abcd commit 271ed16
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 59 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ IMAGES := $(addsuffix -image, ${BINARIES})

VERSION := $(shell git describe --tags)
STRONGSWAN_VERSION = 5.9.1
CNI_PLUGIN_VERSION := v0.9.1

BUILD_TIME := $(shell date -u '+%Y-%m-%d_%H:%M:%S%z')
GIT_COMMIT := $(shell git rev-parse --short HEAD)
Expand Down Expand Up @@ -79,7 +78,7 @@ buildx-install:

${IMAGES}: APP=$(subst -image,,$@)
${IMAGES}: buildx-install
docker build -t fabedge/${APP}:${VERSION} $(if $(PLATFORM),--platform $(PLATFORM)) $(if $(PUSH),--push) $(if $(subst agent,,${APP}),,--build-arg pluginVersion=${CNI_PLUGIN_VERSION}) -f build/${APP}/Dockerfile .
docker build -t fabedge/${APP}:${VERSION} $(if $(PLATFORM),--platform $(PLATFORM)) $(if $(PUSH),--push) -f build/${APP}/Dockerfile .

fabedge-images: ${IMAGES}

Expand Down
20 changes: 5 additions & 15 deletions build/agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
FROM golang:1.17.13 as builder
ARG pluginVersion=v0.9.1
COPY . /fabedge
RUN cd /tmp && git clone https://gitee.com/fabedge/plugins.git && \
cd /tmp/plugins && git checkout ${pluginVersion} && bash build_linux.sh -ldflags "-extldflags -static -X 'github.com/containernetworking/plugins/pkg/utils/buildversion.BuildVersion=${pluginVersion}'" && \
cd /tmp/plugins/bin && cp bridge host-local loopback portmap bandwidth /tmp/ && \
cd /fabedge && make agent QUICK=1 CGO_ENABLED=0 GOPROXY=https://goproxy.cn,direct && \
chmod a+x /fabedge/pkg/agent/env_prepare.sh && \
cp /fabedge/pkg/agent/env_prepare.sh /tmp
RUN cd /fabedge && make agent QUICK=1 CGO_ENABLED=0 GOPROXY=https://goproxy.cn,direct

FROM fabedge/cni-plugins:v1.4.0 as cni-plugins

FROM fabedge/base-image:0.1.0

COPY --from=builder /fabedge/build/agent/entrypoint.sh /
COPY --from=builder /fabedge/_output/fabedge-agent \
/tmp/bridge \
/tmp/host-local \
/tmp/loopback \
/tmp/portmap \
/tmp/bandwidth \
/tmp/env_prepare.sh \
/usr/local/bin/
COPY --from=builder /fabedge/_output/fabedge-agent /usr/local/bin
COPY --from=cni-plugins /plugins/ /plugins

ENTRYPOINT ["/entrypoint.sh"]
26 changes: 13 additions & 13 deletions coredns/plugin/kubernetes/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,41 +40,41 @@ var dnsTestCases = []test.Case{
},
{
Qname: "svc1.testns.svc.cluster.local.", Qtype: dns.TypeSRV,
Rcode: dns.RcodeSuccess,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{test.SRV("svc1.testns.svc.cluster.local. 5 IN SRV 0 100 80 svc1.testns.svc.cluster.local.")},
Extra: []dns.RR{test.A("svc1.testns.svc.cluster.local. 5 IN A 10.0.0.1")},
Extra: []dns.RR{test.A("svc1.testns.svc.cluster.local. 5 IN A 10.0.0.1")},
},
{
Qname: "svcempty.testns.svc.cluster.local.", Qtype: dns.TypeSRV,
Rcode: dns.RcodeSuccess,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{test.SRV("svcempty.testns.svc.cluster.local. 5 IN SRV 0 100 80 svcempty.testns.svc.cluster.local.")},
Extra: []dns.RR{test.A("svcempty.testns.svc.cluster.local. 5 IN A 10.0.0.1")},
Extra: []dns.RR{test.A("svcempty.testns.svc.cluster.local. 5 IN A 10.0.0.1")},
},
{
Qname: "svc6.testns.svc.cluster.local.", Qtype: dns.TypeSRV,
Rcode: dns.RcodeSuccess,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{test.SRV("svc6.testns.svc.cluster.local. 5 IN SRV 0 100 80 svc6.testns.svc.cluster.local.")},
Extra: []dns.RR{test.AAAA("svc6.testns.svc.cluster.local. 5 IN AAAA 1234:abcd::1")},
Extra: []dns.RR{test.AAAA("svc6.testns.svc.cluster.local. 5 IN AAAA 1234:abcd::1")},
},
// SRV Service (wildcard)
{
Qname: "svc1.*.svc.cluster.local.", Qtype: dns.TypeSRV,
Rcode: dns.RcodeSuccess,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{test.SRV("svc1.*.svc.cluster.local. 5 IN SRV 0 100 80 svc1.testns.svc.cluster.local.")},
Extra: []dns.RR{test.A("svc1.testns.svc.cluster.local. 5 IN A 10.0.0.1")},
Extra: []dns.RR{test.A("svc1.testns.svc.cluster.local. 5 IN A 10.0.0.1")},
},
{
Qname: "svcempty.*.svc.cluster.local.", Qtype: dns.TypeSRV,
Rcode: dns.RcodeSuccess,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{test.SRV("svcempty.*.svc.cluster.local. 5 IN SRV 0 100 80 svcempty.testns.svc.cluster.local.")},
Extra: []dns.RR{test.A("svcempty.testns.svc.cluster.local. 5 IN A 10.0.0.1")},
Extra: []dns.RR{test.A("svcempty.testns.svc.cluster.local. 5 IN A 10.0.0.1")},
},
// SRV Service (wildcards)
{
Qname: "*.any.svc1.*.svc.cluster.local.", Qtype: dns.TypeSRV,
Rcode: dns.RcodeSuccess,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{test.SRV("*.any.svc1.*.svc.cluster.local. 5 IN SRV 0 100 80 svc1.testns.svc.cluster.local.")},
Extra: []dns.RR{test.A("svc1.testns.svc.cluster.local. 5 IN A 10.0.0.1")},
Extra: []dns.RR{test.A("svc1.testns.svc.cluster.local. 5 IN A 10.0.0.1")},
},
// A Service (wildcards)
{
Expand Down Expand Up @@ -206,7 +206,7 @@ var dnsTestCases = []test.Case{
// AAAA
{
Qname: "5678-abcd--2.hdls1.testns.svc.cluster.local", Qtype: dns.TypeAAAA,
Rcode: dns.RcodeSuccess,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{test.AAAA("5678-abcd--2.hdls1.testns.svc.cluster.local. 5 IN AAAA 5678:abcd::2")},
},
// CNAME External
Expand Down
15 changes: 0 additions & 15 deletions pkg/agent/env_prepare.sh

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/operator/controllers/agent/agentpodhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (handler *agentPodHandler) buildAgentPod(namespace, podName string, node co
Image: handler.agentImage,
ImagePullPolicy: handler.imagePullPolicy,
Command: []string{
"env_prepare.sh",
"/plugins/env_prepare.sh",
},
SecurityContext: &corev1.SecurityContext{
Privileged: &privileged,
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/controllers/agent/agentpodhandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ var _ = Describe("AgentPodHandler", func() {
Expect(epContainer.Name).To(Equal("environment-prepare"))
Expect(epContainer.Image).To(Equal(agentImage))
Expect(epContainer.ImagePullPolicy).To(Equal(handler.imagePullPolicy))
Expect(epContainer.Command).To(ConsistOf("env_prepare.sh"))
Expect(epContainer.Command).To(ConsistOf("/plugins/env_prepare.sh"))
Expect(*epContainer.SecurityContext.Privileged).To(BeTrue())
Expect(epContainer.VolumeMounts).To(Equal([]corev1.VolumeMount{
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/controllers/connector/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// 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
// 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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/types/agent_argument_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func NewAgentArgumentMap() AgentArgumentMap {
// NewAgentArgumentMapFromEnv extract arguments of agent pod
// from ENV, each agent argument should be configured like:
//
// AGENT_ARG_ENABLE_IPAM=true
// AGENT_ARG_ENABLE_IPAM=true
//
// The return value is a map, each key is the ENV variable name but with
// prefix 'AGENT_ARG_' stripped and the key is also lowered.
Expand Down
20 changes: 10 additions & 10 deletions third_party/ipset/ipset.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ const IPSetCmd = "ipset"

// EntryMemberPattern is the regular expression pattern of ipset member list.
// The raw output of ipset command `ipset list {set}` is similar to,
//Name: foobar
//Type: hash:ip,port
//Revision: 2
//Header: family inet hashsize 1024 maxelem 65536
//Size in memory: 16592
//References: 0
//Members:
//192.168.1.2,tcp:8080
//192.168.1.1,udp:53
// Name: foobar
// Type: hash:ip,port
// Revision: 2
// Header: family inet hashsize 1024 maxelem 65536
// Size in memory: 16592
// References: 0
// Members:
// 192.168.1.2,tcp:8080
// 192.168.1.1,udp:53
var EntryMemberPattern = "(?m)^(.*\n)*Members:\n"

// VersionPattern is the regular expression pattern of ipset version string.
Expand Down Expand Up @@ -123,7 +123,7 @@ func (set *IPSet) Validate() bool {
return true
}

//setIPSetDefaults sets some IPSet fields if not present to their default values.
// setIPSetDefaults sets some IPSet fields if not present to their default values.
func (set *IPSet) setIPSetDefaults() {
// Setting default values if not present
if set.HashSize == 0 {
Expand Down

0 comments on commit 271ed16

Please sign in to comment.