// generateCorefile will generate a coredns corefile, only if not already present on the system
// with settings from the cluster configuration and local system. It should not overwrite an existing
// Corefile, as that may have been modified by a user.
generateCorefile will generate a coredns corefile, only if not already present on the system
with settings from the cluster configuration and local system. It should not overwrite an existing
Corefile, as that may have been modified by a user.
// generateCorefile will generate a coredns corefile only if not already present on the system // with settings from the cluster configuration and local system . It should not overwrite an existing // Corefile as that may have been modified by a user .
func (p *updatePhaseCoreDNS) generateCorefile(ctx context.Context) error {
	p.Info("Generating CoreDNS Corefile.")
	conf, err := libinstall.GenerateCorefile(libinstall.CorednsConfig{
		Hosts: p.DNSOverrides.Hosts,
		Zones: p.DNSOverrides.Zones,
	})
	if err != nil {
		return trace.Wrap(err)
	}
	p.Debug("Generated corefile: ", conf)
	_, err = p.Client.CoreV1().ConfigMaps(constants.KubeSystemNamespace).
		Create(ctx, &v1.ConfigMap{
			ObjectMeta: metav1.ObjectMeta{
				Name:      "coredns",
				Namespace: constants.KubeSystemNamespace,
			},
			Data: map[string]string{
				"Corefile": conf,
			},
		}, metav1.CreateOptions{})
	err = rigging.ConvertError(err)
	if err != nil && !trace.IsAlreadyExists(err) {
		return trace.Wrap(err)
	}
	return nil
}
func ( p * updatePhaseCoreDNS ) generateCorefile ( ctx context . Context ) error { p . Info ( " " ) conf , err := libinstall . GenerateCorefile ( libinstall . CorednsConfig { Hosts : p . DNSOverrides . Hosts , Zones : p . DNSOverrides . Zones , } ) if err != nil { return trace . Wrap ( err ) } p . Debug ( " " , conf ) _ , err = p . Client . CoreV1 ( ) . ConfigMaps ( constants . KubeSystemNamespace ) . Create ( ctx , & v1 . ConfigMap { ObjectMeta : metav1 . ObjectMeta { Name : " " , Namespace : constants . KubeSystemNamespace , } , Data : map [ string ] string { " " : conf , } , } , metav1 . CreateOptions { } ) err = rigging . ConvertError ( err ) if err != nil && ! trace . IsAlreadyExists ( err ) { return trace . Wrap ( err ) } return nil }
generateCorefile will generate a coredns corefile, only if not already present on the system
with settings from the cluster configuration and local system.
generateCorefile will generate a coredns corefile only if not already present on the system with settings from the cluster configuration and local system .