Documentation ¶
Overview ¶
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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.
Index ¶
- Constants
- Variables
- func ExtractCA(s *v1.Secret) ([]byte, error)
- func ExtractKeyPair(s *v1.Secret, hasPrivateKey bool) ([]byte, []byte, error)
- func ValidateRemoteAddrs(remoteAddrs []string) error
- type TranslateContext
- func (tc *TranslateContext) AddGlobalRule(gr *apisix.GlobalRule)
- func (tc *TranslateContext) AddPluginConfig(pc *apisix.PluginConfig)
- func (tc *TranslateContext) AddRoute(r *apisix.Route)
- func (tc *TranslateContext) AddSSL(ssl *apisix.Ssl)
- func (tc *TranslateContext) AddStreamRoute(sr *apisix.StreamRoute)
- func (tc *TranslateContext) AddUpstream(u *apisix.Upstream)
- func (tc *TranslateContext) CheckUpstreamExist(name string) (ok bool)
- type TranslateError
- type Translator
- type TranslatorOptions
Constants ¶
const ( MetaSecretNamespace = "meta_secret_namespace" MetaSecretName = "meta_secret_name" )
const (
DefaultWeight = 100
)
Variables ¶
var ( // ErrUnknownSecretFormat means the secret doesn't contain required fields ErrUnknownSecretFormat = errors.New("unknown secret format") // ErrEmptyCert means the cert field in Kubernetes Secret is not found. ErrEmptyCert = errors.New("missing cert field") // ErrEmptyPrivKey means the key field in Kubernetes Secret is not found. ErrEmptyPrivKey = errors.New("missing key field") )
Functions ¶
func ExtractKeyPair ¶
ExtractKeyPair extracts certificate and private key pair from secret Supports APISIX style ("cert" and "key") and Kube style ("tls.crt" and "tls.key) If hasPrivateKey == false, also support extract CA from "ca.crt"
func ValidateRemoteAddrs ¶
Types ¶
type TranslateContext ¶
type TranslateContext struct { Routes []*apisix.Route StreamRoutes []*apisix.StreamRoute Upstreams []*apisix.Upstream UpstreamMap map[string]struct{} SSL []*apisix.Ssl PluginConfigs []*apisix.PluginConfig GlobalRules []*apisix.GlobalRule }
TranslateContext contains APISIX resources generated by the translator.
func DefaultEmptyTranslateContext ¶
func DefaultEmptyTranslateContext() *TranslateContext
func (*TranslateContext) AddGlobalRule ¶
func (tc *TranslateContext) AddGlobalRule(gr *apisix.GlobalRule)
func (*TranslateContext) AddPluginConfig ¶
func (tc *TranslateContext) AddPluginConfig(pc *apisix.PluginConfig)
func (*TranslateContext) AddRoute ¶
func (tc *TranslateContext) AddRoute(r *apisix.Route)
func (*TranslateContext) AddSSL ¶
func (tc *TranslateContext) AddSSL(ssl *apisix.Ssl)
func (*TranslateContext) AddStreamRoute ¶
func (tc *TranslateContext) AddStreamRoute(sr *apisix.StreamRoute)
func (*TranslateContext) AddUpstream ¶
func (tc *TranslateContext) AddUpstream(u *apisix.Upstream)
func (*TranslateContext) CheckUpstreamExist ¶
func (tc *TranslateContext) CheckUpstreamExist(name string) (ok bool)
type TranslateError ¶
func (*TranslateError) Error ¶
func (te *TranslateError) Error() string
type Translator ¶
type Translator interface { // TranslateUpstreamConfigV2 translates ApisixUpstreamConfig (part of ApisixUpstream) // to APISIX Upstream, it doesn't fill the the Upstream metadata and nodes. TranslateUpstreamConfigV2(*configv2.ApisixUpstreamConfig) (*apisixv1.Upstream, error) // TranslateUpstream composes an upstream according to the // given namespace, name (searching Service/Endpoints) and port (filtering Endpoints). // The returned Upstream doesn't have metadata info. // It doesn't assign any metadata fields, so it's caller's responsibility to decide // the metadata. // Note the subset is used to filter the ultimate node list, only pods whose labels // matching the subset labels (defined in ApisixUpstream) will be selected. // When the subset is not found, the node list will be empty. When the subset is empty, // all pods IP will be filled. TranslateService(string, string, string, int32) (*apisixv1.Upstream, error) // TranslateUpstreamNodes translate Endpoints resources to APISIX Upstream nodes // according to the give port. Extra labels can be passed to filter the ultimate // upstream nodes. TranslateEndpoint(kube.Endpoint, int32, types.Labels) (apisixv1.UpstreamNodes, error) }
func NewTranslator ¶
func NewTranslator(opts *TranslatorOptions) Translator
NewTranslator initializes a APISIX CRD resources Translator.
type TranslatorOptions ¶
type TranslatorOptions struct { APIVersion string IngressClassName string EndpointLister kube.EndpointLister ServiceLister listerscorev1.ServiceLister SecretLister listerscorev1.SecretLister PodLister listerscorev1.PodLister ApisixUpstreamLister kube.ApisixUpstreamLister PodProvider pod.Provider }
TranslatorOptions contains options to help Translator work well.